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

[Fix] to make it windows "ping" compatible. #1

Closed
Andy2244 opened this issue Jan 27, 2016 · 6 comments
Closed

[Fix] to make it windows "ping" compatible. #1

Andy2244 opened this issue Jan 27, 2016 · 6 comments

Comments

@Andy2244
Copy link

Hi,

i used Gow linux environment under windows to run the script, but the ping syntax is different. I added a fix to make it more compatible. I also requested to add the linux ping command to Gow so the script will run on windows without changes.

Tested using: (https://github.com/bmatzelle/gow/wiki) + bash install fix (bmatzelle/gow#65 (comment))

Script fix:

# Make a short ping and from the output, save the millisecond time
echo -n "Pinging $server_url ... "
if [ "$OS" = "Windows_NT" ] ; then
    time_str=$(ping -n 1 -l 16 -w 1000 $server_url 2> /dev/null | grep time | awk -F'=' '{print $3}' | awk '{print $1}' | awk '{print substr($0,1,length()-2)}')
else
    time_str=$(ping -c 1 -q -s 16 -w 1 -W 1 $server_url 2> /dev/null | grep avg | awk -F'/' '{print $5}')
fi

thx
Andy

@chris-marsh
Copy link
Owner

Thanks Andy.

I'd like to include the fix for Windows, but I don't have a system to test on. Do the other features work?

Especially starting / stopping openvpn

Does the script correctly use paths to find config files, etc

Adding one fix for Windows would imply the script is compatible for that system. Can you confirm it is, or suggest fixes?

Cheers,
Chris.

@Andy2244
Copy link
Author

Hi Chris,

i did not test start/stop openvpn, since i use the Viscosity client and not the community openvpn client. From what i can see this feature will not work, since the "pidof" is missing. The native windows command is "tasklist" with a output like this:

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0 Services                   0          4 K
System                           4 Services                   0        380 K
smss.exe                       404 Services                   0      1.152 K
csrss.exe                      588 Services                   0      4.156 K

The script writes the config files, but the scriptpath under the emulation looks like this: "/c/Downloads/fastIPvanish-master". If you try to import this file using any openvpn windows client, the ca/auth-user-pass file will not be found, since the driveletter format should be "c:" or "c:/", so some conversion needs to happen for the absolute path. Alternatively most tools will happily use relative paths like "./etc/ca.ipvanish.com.crt" based on the config.ovpn location, so just don't use the scriptfilepath at all in the output file and write relative paths.

So except for the process start/stop everything else should work, if the path is fixed for the config files.

bye
Andy

PS: Btw isn't it possible and faster to start multiple pings at the same time (maybe 5-10) so the script can finish faster?

@chris-marsh
Copy link
Owner

Andy, thanks for the detailed feedback. I'll try and look into windows compatability next week ... we have Windows machines at work I can test on.

As for speeding things up, try the latest version. Hopefully it makes it better?

0ac3964

I'm thinking about adding a 'silent' option, ie "just do the ping and write the config without bothering me". Also an option to accept defaults to automatically start openvpn without prompting. I think that would make the script useful during boot/login/startup situations.

@Andy2244
Copy link
Author

Does not work, since it has no windows ping options and the temp file handling is broken it seems.

I guess you need to test this on a real windows machine or some emulation. The path/temp handling will differ on windows.

bye
Andy

@chris-marsh
Copy link
Owner

Hopefully fixed now.

@Andy2244
Copy link
Author

If i manually add my windows ping fix it runs, but the paths inside the generated config are still absolute, using the bad formatted drive letter.

Here is what the file looks like for me:

client
dev tun
proto udp
remote ams-a22.ipvanish.com 443
resolv-retry infinite
nobind
persist-key
persist-tun
persist-remote-ip
ca /c/Downloads/fastIPvanish-master(1)/fastIPvanish-master/etc/ca.ipvanish.com.crt
remote-cert-tls server
auth-nocache
auth-user-pass /c/Downloads/fastIPvanish-master(1)/fastIPvanish-master/etc/login.conf
comp-lzo
verb 3
auth SHA256
cipher AES-256-CBC
keysize 256
tls-cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA

chris-marsh pushed a commit that referenced this issue Aug 8, 2022
…-workarounds

added comments for workarounds with openssl3 and lan no route
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants