Skip to content

Commit 3230079

Browse files
committed
When on WSL2, check for internal host IP
Added line to check for the internal host IP before checking the external IP addresses. Also now parse the options before calling check_host, so that any passed in options can be used in the check_host function.
1 parent 101528b commit 3230079

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

runx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ check_host() { # Check host environment
326326

327327
# Get IP of Windows host
328328
[ "$Hostip" = "localhost" ] && Hostip="127.0.0.1"
329+
[ "$Hostip" ] || [ "$Winsubsystem" = "WSL2" ] && Hostip="$(ip route list default | awk '{print $3}')"
329330
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | grep -o '192\.168\.[0-9]*\.[0-9]*' | head -n1 )"
330331
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | grep -o '10\.0\.[0-9]*\.[0-9]*' | head -n1 )"
331332
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | head -n1 )"
@@ -777,8 +778,8 @@ export XAUTHORITY=$XAUTHORITY" > "$Xenvfile"
777778

778779
trap finish EXIT
779780
declare_variables
780-
check_host
781781
parse_options "$@"
782+
check_host
782783
[ "$Cleanup" = "yes" ] && cleanup && Exitcode="${Exitcode:-0}"
783784
[ -z "$Exitcode" ] && main
784785
finish "${Exitcode:-0}"

0 commit comments

Comments
 (0)