https://github.com/argosylabs/wgnlpy
WireGuard + Netlink + Python
https://github.com/argosylabs/wgnlpy
linux netlink python wireguard
Last synced: 12 months ago
JSON representation
WireGuard + Netlink + Python
- Host: GitHub
- URL: https://github.com/argosylabs/wgnlpy
- Owner: ArgosyLabs
- License: mit
- Created: 2019-08-07T19:11:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-19T12:29:48.000Z (almost 3 years ago)
- Last Synced: 2025-04-10T22:48:53.017Z (12 months ago)
- Topics: linux, netlink, python, wireguard
- Language: Python
- Homepage:
- Size: 38.1 KB
- Stars: 44
- Watchers: 4
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wgnlpy
Python netlink connector to WireGuard
======
A simple control interface for [WireGuard](https://www.wireguard.com/) via
Netlink, written in Python.
```python
from wgnlpy import WireGuard
interface = "wg0"
peer = b'...'
wg = WireGuard()
wg.set_peer(interface, peer,
endpoint="203.0.113.0:51820",
allowedips=["2001:db8::/32"],
)
assert peer in wg.get_interface(interface).peers
wg.remove_peers(interface, peer)
assert peer not in wg.get_interface(interface).peers
```
Requires
* [cryptography](https://cryptography.io/), &
* [pyroute2](https://pyroute2.org/).
Also useful: the `sockaddr_in` and `sockaddr_in6` utility classes for
sockaddr manipulation.
License: [MIT](https://opensource.org/licenses/MIT)