An API for managing an OpenVPN connection
Project description
Python OpenVPN Client
This package allows an OpenVPN connection to be established
seamlessly given a config.ovpn file and then later be
disconnected when instructed to. The functionality is tested to
work on macOS and Linux (images: macOS-latest and ubuntu-24.04).
Note: Testing requires openvpn >= 2.6 since the used peer-fingerprint
feature was first introduced then.
Authors
- Ludvig Larsson - lular@kth.se
- Nikolaos Kakouros - nkak@kth.se
- Benjamin Kelley - bekelley@kth.se
Command line usage
# connect
python3 -m openvpnclient --config=path/to/ovpn/config
# disconnect
python3 -m openvpnclient --disconnect
Usage in code
from openvpnclient import OpenVPNClient
# manually connect and disconnect
vpn = OpenVPNClient(ovpn_file)
vpn.connect()
# interact with network
vpn.disconnect()
# utilize context handler
with OpenVPNClient(ovpn_file):
# interact with network
Contributing
Create virtual environment and install dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r prod-requirements.txt
After making changes, make sure the tests pass:
pip install -r test-requirements.txt
pytest tests/test_openvpnclient.py -s -v
Create a PR from the feature branch with the incorporated changes.
Test cases
- Manually connect and disconnect the OpenVPN client
- Use context manager to connect and disconnect the OpenVPN client
- Disconnect client on SIGINT (ctrl+c)
- Disconnect when not connected
- Connect when already connected
- Invalid configuration syntax
- Unreachable server
- Invalid path to ovpn config file
- Connection attempt timeout
An autouse fixture (await_openvpn_cleanup) forces a delay between
all tests. Given the rapid closing and opening of the same socket, this
timeout can be adjusted to make sure the socket is ready for
subsequent test.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_openvpn_client-0.0.1.tar.gz.
File metadata
- Download URL: python_openvpn_client-0.0.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eec2b80b327925a28340bf08d6e8ec668181fb845ac600313c4c96413e9ed030
|
|
| MD5 |
62fd6ef142865e9ba81a2ae84185d097
|
|
| BLAKE2b-256 |
ad73c58e538b726d34eaa4b1917c1680dfb3c11c18f68387ab949f627e00ddbf
|
File details
Details for the file python_openvpn_client-0.0.1-py3-none-any.whl.
File metadata
- Download URL: python_openvpn_client-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f2f66bece4de5ed80fe14111aba58d3548cc83c68808b1d8b4231ebfe03c8f1
|
|
| MD5 |
332096f86238e724a05e624c789ec139
|
|
| BLAKE2b-256 |
2a5113fddf3e9413768f2b3a6dbf3f517571aa8059febe3eb0662b5ea8acca17
|