Yicong-Huang commented on code in PR #7141:
URL: https://github.com/apache/texera/pull/7141#discussion_r3787846855
##########
bin/local-dev/main.sh:
##########
@@ -590,9 +590,85 @@ fi
# docker network. The host's LAN IP works from BOTH (host loopback for the
# host, docker NAT'd out-and-back for the container).
#
-# Both platform probes follow the same two steps: the interface backing the
+# All three platform probes follow the same two steps: the interface backing
the
# default route first (most reliable on a laptop that may have wifi +
# thunderbolt + tailscale all active), then a scan as a fallback.
+_detect_host_lan_ip_windows() {
+ local iface_details="" local_ip="" iface_name="" idx=""
+
+ local
virt_excl="vEthernet|WSL|Hyper-V|VirtualBox|Docker|Bridge|tap|tun|cni|flannel|cali|kube|tailscale|zerotier|wg|McAfee"
+ # Use 'netsh interface ip show route' to find the list of interfaces
+ # associated with the 0.0.0.0/0 (default) route and trace the respective
indices
+ local idx_list
+ idx_list=$(netsh interface ip show route 2>/dev/null | \
+ awk '{
+ for (i = 1; i < NF; i++) {
+ if ($i == "0.0.0.0/0") {
+ print $(i+1)
+ }
+ }
+ }')
+
+ # Iterate through candidate indices, inspect adapter name and grab the
first physical LAN IP
+ for idx in $idx_list; do
+ iface_details=$(netsh interface ip show addresses "$idx" 2>/dev/null)
+
+ # Skip if adapter name is empty or matches virtual/VPN exclusions
+ iface_name=$(echo "$iface_details" | awk -F'"' '/Configuration for
interface/ {print $2}')
+ if [[ -z "$iface_name" ]] || echo "$iface_name" | grep -qiE
"$virt_excl"; then
+ continue
+ fi
+
+ # Get the IPv4 address of the interface
+ local_ip=$(echo "$iface_details" | awk -F': ' '/IP Address/ {print $2;
exit}' | tr -d ' \r')
+ # Validate non-loopback and non-APIPA (169.254.x.x) address
+ if [[ -n "$local_ip" && "$local_ip" != 127.* && "$local_ip" !=
169.254.* ]]; then
+ printf '%s\n' "$local_ip"
+ return 0
+ fi
+ done
+
+ # =========================================================================
+ # FALLBACK METHOD: Parse all 'netsh' interface blocks sequentially
+ # =========================================================================
+ # If the default route method fails, we dump all interface configurations.
+ # Parse the output statefully using awk to track which interface block
+ # we are currently reading, skip explicitly excluded virtual/bridge
interfaces,
+ # and return the first valid, globally routable IPv4 address we find.
Review Comment:
The block promises "globally routable", but the guards below reject only
`127.` and `169.254.`. An RFC1918 address is not globally routable — and it is
exactly what this function must return (`:584`). Worth fixing so a later editor
doesn't add a private-range filter to match the prose.
```suggestion
# and return the first valid non-loopback, non-APIPA IPv4 address we
find.
```
##########
bin/local-dev/main.sh:
##########
@@ -664,7 +741,9 @@ _require_host_lan_ip() {
Darwin) probes="\`route get default\` / en0-en10" ;;
Linux) probes="\`ip route show default\` / \`ip -4 addr show
scope global\`"
bridge_note=" outside the container bridges" ;;
- *) probes="the macOS and Linux probes"
+ MINGW*|MSYS*|CYGWIN*|*_NT*) probes="\`netsh interface ip show
route\` / \`netsh interface ip show addresses\`"
Review Comment:
Trailing whitespace here, and on `:635` and `:636` — the same class as the
`:621` line this round removed. Nothing lints it, so purely cosmetic.
```suggestion
MINGW*|MSYS*|CYGWIN*|*_NT*) probes="\`netsh interface ip show
route\` / \`netsh interface ip show addresses\`"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]