Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion bin/local-dev/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,15 @@ 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 ip=""
ip=$(ipconfig 2>/dev/null | grep -i "IPv4" | head -n 1 | awk -F: '{print $2}' | tr -d '[:space:]' | tr -d '\r')
if [[ -n "$ip" && "$ip" != 127.* ]]; then
printf '%s\n' "$ip"; return 0;
fi
return 1
}

_detect_host_lan_ip_darwin() {
local iface="" ip=""
iface=$(route get default 2>/dev/null | awk '/interface:/{print $2; exit}')
Expand Down Expand Up @@ -520,8 +529,9 @@ _detect_host_lan_ip() {
case "$(uname -s 2>/dev/null)" in
Darwin) _detect_host_lan_ip_darwin ;;
Linux) _detect_host_lan_ip_linux ;;
MINGW*|MSYS*|CYGWIN*|*_NT*) _detect_host_lan_ip_windows ;;
# Anything else (BSD, WSL oddities): try both rather than give up.
*) _detect_host_lan_ip_darwin || _detect_host_lan_ip_linux ;;
*) _detect_host_lan_ip_darwin || _detect_host_lan_ip_linux || _detect_host_lan_ip_windows ;;
esac
}
# Lazy resolver — called from subcommands that actually need to publish a
Expand Down
Loading