A pure Python implementation of WireGuard
Project description
Python WireGuard
A pure python implementation of the WireGuard protocol.
Table of contents
Motivation
Existing Python libraries for WireGuard rely on the system daemon, which limits flexibility, requires root access, and causes global network changes. A user-mode implementation avoids these issues, making setup easier and safer for isolated use cases. It also enables custom packet injection (IPv4/IPv6) without raw sockets, making it useful for things like anonymous SYN scans (given proper spoofing), dynamic IP hopping for scraping, or building VPN-like tools without system-wide impact. And finally, because why not? It's a fun project to learn about the WireGuard protocol and networking in general.
Performance
One major drawback of this implementation is its speed. While rewriting it in a faster language like C++ with Python bindings could solve this, it would also add significant complexity. For now, the focus is on optimizing the existing Python code as much as possible.
Usage
For usage examples please refer to the examples directory. The examples demonstrate how to use the library to create WireGuard peers, encode packets, send packets, and manage inbound packets.
A documentation will be added in the future, but for now, the examples should provide enough information to get started.
Testing and troubleshooting
If you encounter any issues while using the library please first run the test suite to check if any tests are failing. The tests can be run by using python run_tests.py in the root directory of the project.
If anything fails or doesn't work properly please feel free to open an issue on the repository with the details of the issue and the output of the tests.
References
The following references were used while building this project:
- WireGuard paper
- WireGuard website
- wireguard-lwip by smartalock
- RFC 791 (IPv4 standard)
- RFC 8200 (IPv6 standard)
- IANA DSCP & ECN (IPv4/IPv6 DSCP and ECN)
- IANA Protocol Numbers (IPv4/IPv6 Protocol Numbers)
- RFC 768 (UDP standard)
- RFC 9293 (TCP standard)
- IANA TCP Parameters (TCP enumerators, options, etc)
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 wireguard_protocol-0.0.6.tar.gz.
File metadata
- Download URL: wireguard_protocol-0.0.6.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a6aeac15cbf206600267c677774df327b96c295d322f86202ceb957f0d726e3
|
|
| MD5 |
c44366f5cd10073f07b28cd6d184be15
|
|
| BLAKE2b-256 |
5748f773080830df05359a3b59cf197f65950850b12a8c60018dd87d4b129761
|
File details
Details for the file wireguard_protocol-0.0.6-py3-none-any.whl.
File metadata
- Download URL: wireguard_protocol-0.0.6-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c36769f524306695fb452609735e9a4553e358aed3d9da91c3273564b9b802d6
|
|
| MD5 |
0f47f537792fd91990533dd444e2ef8a
|
|
| BLAKE2b-256 |
927df4e7c5aa891f8b2194230c8efde1cd301442b6f36cc50f06b8380916223a
|