Mrudhulraj commented on code in PR #7141:
URL: https://github.com/apache/texera/pull/7141#discussion_r3787360626


##########
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:
   Added the appropriate comments to handle all three possible platform probes.
   
   Handled the case-sensitive case mentioned in `:639`



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