Skip to main content

A function to ensure you are connected to your favorite VPN before running your script.

Project description

A Python function to ensure 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

  • Mullvad
  • NordVPN

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 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

ensure_vpn-0.1.1.tar.gz (15.1 kB view hashes)

Uploaded Source

Built Distribution

ensure_vpn-0.1.1-py3-none-any.whl (16.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page