21 lines
532 B
Python
21 lines
532 B
Python
|
from pywireguard.factory import Interface, Peer
|
||
|
|
||
|
|
||
|
class WGManager:
|
||
|
interface: str
|
||
|
|
||
|
def __init__(self, interface: str):
|
||
|
self.interface = interface
|
||
|
|
||
|
def get_peers(self) -> list[Peer]:
|
||
|
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)
|