Closed dizcza closed 5 years ago
@dizcza Just file a pull request, I guess.
Nordvpn team (I guess, not sure) made linux package that you can install with
sudo apt install nordpvn
Then wrap your python function with the decorator:
def nordvpn(func):
def under_vpn(*args, **kwargs):
subprocess.call('nordvpn connect'.split())
res = func(*args, **kwargs)
subprocess.call('nordvpn disconnect'.split())
return res
return under_vpn
Usage:
@nordvpn
def your_function_that_you_want_to_run_under_vpn():
pass
I've been using it for months and it works flawlessly and does not require sudo at runtime.
If your_function_that_you_want_to_run_under_vpn
might exit with non-zero error code, you can always register a callback that closes opened nordvpn connection with atexit
even if an error is occured.
sudo apt install nordvpn
I want to use
openpyn
directly in python code. If it's already written in python, could you please provide API for doing this? Basically, my scenario is the following:I think I can do this with
subprocess
though maybe there is direct way toimport openpyn
and call it.