Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(fix host ip): using gateway ip, nameserver ip not working #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions assets/GWSL_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ then
then
# Configure Fish
sed -i.bak '/DISPLAY /d' ~/.config/fish/config.fish
echo "set -gx DISPLAY (cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.config/fish/config.fish
echo "set -gx DISPLAY (ip route list default | awk '{print \$3; exit;}'):0.0 #GWSL" >> ~/.config/fish/config.fish
elif [ $wsl_shell == "zsh" ]
then
# Configure Zsh
sed -i.bak '/DISPLAY=/d' ~/.zshrc
echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.zshrc
echo "export DISPLAY=\$(ip route list default | awk '{print \$3; exit;}'):0.0 #GWSL" >> ~/.zshrc
elif [ $wsl_shell == "bash" ]
then
# Configure Bash
sed -i.bak '/DISPLAY=/d' ~/.profile
echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.profile
echo "export DISPLAY=\$(ip route list default | awk '{print \$3; exit;}'):0.0 #GWSL" >> ~/.profile
sed -i.bak '/DISPLAY=/d' ~/.bashrc
echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.bashrc
echo "export DISPLAY=\$(ip route list default | awk '{print \$3; exit;}'):0.0 #GWSL" >> ~/.bashrc
fi
fi

Expand Down Expand Up @@ -91,19 +91,19 @@ then
then
# Configure Fish
sed -i.bak '/PULSE_SERVER /d' ~/.config/fish/config.fish
echo "set -gx PULSE_SERVER tcp:(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.config/fish/config.fish
echo "set -gx PULSE_SERVER tcp:(ip route list default | awk '{print \$3; exit;}') #GWSL" >> ~/.config/fish/config.fish
elif [ $wsl_shell == "zsh" ]
then
# Configure Zsh
sed -i.bak '/PULSE_SERVER=/d' ~/.zshrc
echo "export PULSE_SERVER=tcp:\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.zshrc
echo "export PULSE_SERVER=tcp:\$(ip route list default | awk '{print \$3; exit;}') #GWSL" >> ~/.zshrc
elif [ $wsl_shell == "bash" ]
then
# Configure Bash
sed -i.bak '/PULSE_SERVER=/d' ~/.profile
echo "export PULSE_SERVER=tcp:\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.profile
echo "export PULSE_SERVER=tcp:\$(ip route list default | awk '{print \$3; exit;}') #GWSL" >> ~/.profile
sed -i.bak '/PULSE_SERVER=/d' ~/.bashrc
echo "export PULSE_SERVER=tcp:\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.bashrc
echo "export PULSE_SERVER=tcp:\$(ip route list default | awk '{print \$3; exit;}') #GWSL" >> ~/.bashrc
fi
fi

Expand Down
8 changes: 4 additions & 4 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def get_ip(machine):
:return:
"""
#print("get_ip")
cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')""" + '"'
cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """(ip route list default | awk '{print $3}')""" + '"'


#print(cmd)
Expand All @@ -795,15 +795,15 @@ def get_ip(machine):
try:
ipa = ipaddress.ip_address(result)
except:
cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """echo $(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')""" + '"'
result = os.popen(cmd).readlines()[0]
cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """echo $(ip route list default | awk '{print $3; exit;}')""" + '"'
result = os.popen(cmd).readlines()[0].rstrip("\n")
#result = "localhost"


#print("ipa", ipa, "ipd")


#result = runo3(machine, """echo $(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')""")
#result = runo3(machine, """echo $(ip route list default | awk '{print $3; exit;}')""")
#print("ip", result, "done")
return result # [0][:-1]

Expand Down