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
Metadata
Release files for ensure-vpn 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ensure_vpn-0.5.0.tar.gz | 18.3 kB | Without provenance | Details for ensure_vpn-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ensure_vpn-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for ensure_vpn-0.5.0-py3-none-any.whl |
Total release size: 37.8 kB
Release files / ensure_vpn-0.5.0.tar.gz
| Download URL | ensure_vpn-0.5.0.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1dd2a76fff4f4eb9869b9433dd702b89c40ac381d4020d34e1f70bb053c88f15
|
|
BLAKE2b-256 checksum How to use checksums |
c68082b32d74ce9a5e5d6c16b67386a50fca8857f9bd9cbeea49567d5f31a069
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1041-azure
|
Release files / ensure_vpn-0.5.0-py3-none-any.whl
| Download URL | ensure_vpn-0.5.0-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
230cb432493800f4834253f7df9aea450f688c08ffa474aae26de43812420ba9
|
|
BLAKE2b-256 checksum How to use checksums |
7617e1ee5130bf9736873f1f7c462623d07da42bf60380be5bbea641c312a4c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1041-azure
|
Security for ensure-vpn 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.