sfiorini / NordVPN-Wireguard

A bash scripts that generates Wireguard configuration file for a NordVPN connection.
229 stars 40 forks source link

Basic port to Powershell (Windows) #17

Open nmindz opened 9 months ago

nmindz commented 9 months ago

I am using Windows and despite my attempts, configuring NordVPN in WSL and attempting to run the script (which requires NordVPN to successfully connect) was just a painful experience despite the hacks and workarounds - apparently nordvpnd and nordvpn are not intended to work under WSL.

Because of that I needed to make it work in Windows (in order to extract a Wireguard configuration for my UDM Pro, since I didn't want to configure OVPN). This is apparently works and invoking it with -Country seems to produce the expected result.

Different than the Linux nordvpn interface which would require country names such as United_States to query the API properly (unless I got that wrong), the Windows utility is far more limited (such as no support for nordvpn status) so I had to improvise.

Another key difference is that it doesn't seem to support City, Country, etc. like the Linux version does. It only supports Country, ID and Server Name (like United States #9128). So I opted to just implement -Country (which is "group" under nordvpn Windows) and -Id, in case you know exactly what server you want to connect to.

Also, between the NordLynx adapter being available and there actually being connectivity to query the NordVPN API there usually is a delay so I just opted to query a popular IP identification site (WTF Is My IP - my favorite) to ensure there is connectivity before proceeding.

This is by no means exemplary work and I rarely ever do Powershell - that said, since I went through the length of actually making it work, I thought I could share this with the original project. Likewise its Linux counterpart, you'll need to ensure nordvpn and wireguard and installed and available in your PATH before proceeding. I did not hard-code the default paths from %PROGRAMFILES% because installations may differ.

At last, the script requires Admin privileges due to wg.exe not being able to execute and query the interfaces otherwise. You may remove the UAC escalation from the script as long as you ensure wg.exe can work as the unprivileged user. I didn't want to bother going through the effort so I just ensured the script is RunAs an Administrator.

nmindz commented 9 months ago

New dependencies (for Windows):

sfiorini commented 4 months ago

Hi @nmindz , sorry I have been so late getting at this. I am not very good at Powershell, but would love to incorporate your work into the project. Could you please write markdown instructions to install run the Powershel version? Afterwards, I will merge the PR and add a link on the main README to open the windows version install.

nmindz commented 4 months ago

@sfiorini Hey there! Not a problem. 😄

I've updated the README file with instructions for both Linux and Windows (Linux being first/default), including requirements and how to install them on Windows. I had to force push to my fork branch because GPG signing is hard and it had been a while since I had it working last time. lol

If you need something else, let me know, I'll be glad to do/fix it. Cheers!

sfiorini commented 4 months ago

Thank you. Will take a look at it and test it on my Windows machine as soon as I have a chance and integrate it. Your help on the Powershell version is truly appreciated!