Metadata-Version: 2.1
Name: python-openvpn-client
Version: 0.0.1
Summary: An API for managing an OpenVPN connection
Author-email: Ludvig Larsson <lular@kth.se>, Nikolaos Kakouros <nkak@kth.se>, Benjamin Kelley <bekelley@kth.se>
Project-URL: Homepage, https://github.com/KTH-SSAS/python-openvpn-client
Project-URL: Issues, https://github.com/KTH-SSAS/python-openvpn-client/issues
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: psutil
Requires-Dist: docopt
Requires-Dist: typing-extensions

# 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
```bash
# connect
python3 -m openvpnclient --config=path/to/ovpn/config

# disconnect
python3 -m openvpnclient --disconnect
```

## Usage in code
```python
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:
```bash
python3 -m venv venv
source venv/bin/activate
pip install -r prod-requirements.txt
```

After making changes, make sure the tests pass:
```bash
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
1. Manually connect and disconnect the OpenVPN client
1. Use context manager to connect and disconnect the OpenVPN client
1. Disconnect client on SIGINT (ctrl+c)
1. Disconnect when not connected
1. Connect when already connected
1. Invalid configuration syntax
1. Unreachable server
1. Invalid path to ovpn config file
1. 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.
