Yicong-Huang commented on code in PR #7141:
URL: https://github.com/apache/texera/pull/7141#discussion_r3786747309


##########
bin/local-dev/main.sh:
##########
@@ -466,6 +466,40 @@ fi
 # Both 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 idx="" iface_details="" local_ip=""
+
+    local 
virt_excl="vEthernet|WSL|Hyper-V|VirtualBox|Docker|Bridge|tap|tun|cni|flannel|cali|kube|Local|tailscale|zerotier|wg|McAfee"
+
+    # Use 'netsh interface ip show route' to find the interface 
+    # associated with the 0.0.0.0/0 (default) route.
+    idx=$(netsh interface ip show route 2>/dev/null | \
+            awk -v excl="$virt_excl" '{
+                for (i = 1; i < NF; i++) {
+                    if ($i == "0.0.0.0/0") {
+                        # Check if Gateway/Interface name (i+2) matches 
virtual pattern
+                        if ($(i+2) !~ excl) {
+                            print $(i+1)
+                            exit
+                        }
+                    }
+                }
+            }' | head -n 1)
+
+    if [ -n "$idx" ]; then
+        # Query the interface configuration using the Idx value
+        iface_details=$(netsh interface ip show addresses "$idx" 2>/dev/null)
+        local_ip=$(echo "$iface_details" | awk -F': ' '/IP Address/ {print 
$2}' | tr -d ' \r')
+
+        # Check if a valid non-loopback / non-APIPA IP was found
+        if [[ -n "$local_ip" && "$local_ip" != 127.* && "$local_ip" != 
169.254.* ]]; then
+            printf '%s\n' "$local_ip"
+            return 0
+        fi
+    fi
+    return 1

Review Comment:
   The scan landed — `main.sh:631-664`. I drove the extracted function against 
a fake `netsh`: a host with no default route now falls through to it and 
returns the Ethernet address instead of hard-exiting at `_require_host_lan_ip`. 
Half of this thread is done.
   
   Keeping it open for the other half. `main.sh:593` still opens with "Both 
platform probes follow the same two steps", and there are three probes under it 
now — your own new comment on `:719` already says "try all three". One word: 
`All three platform probes follow the same two steps`.
   
   One caveat on the scan itself, which I've raised separately on `:639` — it 
does not exclude the adapters `:618` excludes, so on a full-tunnel host it 
hands back the address step 1 just refused.



-- 
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]

Reply via email to