A function to make sure you are connected to your favorite VPN before running your script.
Project description
A Python function to make sure you are connected to your favorite VPN before running your script or function. It just raises an exception if you're not connected.
Supported VPN providers
- Custom IP
- ExpressVPN (
"expressvpn"
) - HideMyAss (
"hidemyass"
) - Hotspot Shield (
"hotspotshield"
) - IPVanish (
"ipvanish"
) - IVPN (
"ivpn"
) - Mullvad (
"mullvad"
) - NordVPN (
"nordvpn"
) - Private Internet Access (
"privateinternetaccess"
) - ProtonVPN (
"protonvpn"
) - Surfshark (
"surfshark"
) - VyprVPN (
"vyprvpn"
)
Add your own!
Installation
pip install ensure-vpn
Usage
Import the function and run it as the first thing in your script:
from ensure_vpn import ensure_vpn
ensure_vpn("mullvad") # raises VPNNotConnectedException if you're not connected.
# rest of your script goes here
You can also use a custom IP or subnet:
ensure_vpn("2.235.200.110") # or e.g. "2.235.200.0/24"
You can also use the decorator to run the check every time before running a specific function. This is to make sure you don't run untrusted code if you lose your VPN connection after starting your program.
Note that this can be resource intensive depending on how often you call your function so it may slow down your program considerably or get you rate-limited by the services used by this script.
from ensure_vpn import ensure_vpn_decorator
@ensure_vpn_decorator("nordvpn")
def do_stuff():
# ...
do_stuff() # VPN is checked every time you call do_stuff
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ensure_vpn-0.5.0.tar.gz
.
File metadata
- Download URL: ensure_vpn-0.5.0.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dd2a76fff4f4eb9869b9433dd702b89c40ac381d4020d34e1f70bb053c88f15 |
|
MD5 | 5aabfe19f7bafa2d8438cbaf9fb35cdb |
|
BLAKE2b-256 | c68082b32d74ce9a5e5d6c16b67386a50fca8857f9bd9cbeea49567d5f31a069 |
File details
Details for the file ensure_vpn-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: ensure_vpn-0.5.0-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 230cb432493800f4834253f7df9aea450f688c08ffa474aae26de43812420ba9 |
|
MD5 | 6465ed314d15c3c6c8b85757c74cae49 |
|
BLAKE2b-256 | 7617e1ee5130bf9736873f1f7c462623d07da42bf60380be5bbea641c312a4c6 |