wg-manager/wg_connection_manager/wg_manager.py
2024-10-06 12:56:12 +02:00

20 lines
518 B
Python

from pywireguard.factory import Interface, Peer
class WGManager:
interface: str
def __init__(self, interface: str):
self.interface = interface
def get_peers(self):
wginterface = Interface(self.interface)
return wginterface.peers
def add_peer(self, peer: Peer):
wginterface = Interface(self.interface)
wginterface.upsert_peer(peer)
def remove_peer(self, peer: Peer):
wginterface = Interface(self.interface)
wginterface.remove_peer(peer)