Metadata-Version: 2.1
Name: ensure-vpn
Version: 0.1.1
Summary: A function to ensure you are connected to your favorite VPN before running your script.
Home-page: https://github.com/ftruzzi/ensure_vpn
Author: Francesco Truzzi
Author-email: francesco@truzzi.me
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: requests (>=2.25.1,<3.0.0)
Requires-Dist: returns (==0.15.0)
Project-URL: Repository, https://github.com/ftruzzi/ensure_vpn
Description-Content-Type: text/markdown

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:

```python
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.

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

