Skip to content

Commit

Permalink
When on WSL2, check for internal host IP
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RolandRosier committed Jan 8, 2023
1 parent 101528b commit 3230079
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion runx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ check_host() { # Check host environment

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

trap finish EXIT
declare_variables
check_host
parse_options "$@"
check_host
[ "$Cleanup" = "yes" ] && cleanup && Exitcode="${Exitcode:-0}"
[ -z "$Exitcode" ] && main
finish "${Exitcode:-0}"

0 comments on commit 3230079

Please sign in to comment.