add static peer formatting for client config
This commit is contained in:
+5
-2
@@ -1,3 +1,6 @@
|
|||||||
def test_true():
|
from vpn_manager import *
|
||||||
assert True
|
|
||||||
|
|
||||||
|
def test_format_static_peer():
|
||||||
|
sp = StaticPeer('sample-public-key', '127.0.0.1', '12345')
|
||||||
|
peer_section = format_static_peer(sp, '0.0.0.0/0')
|
||||||
|
assert peer_section == '[Peer]\nPublicKey = sample-public-key\nAllowedIPs = 0.0.0.0/0\nEndpoint = 127.0.0.1:12345\nPersistentKeepAlive = 30'
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
from .__main__ import *
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class StaticPeer:
|
||||||
|
public_key: str
|
||||||
|
endpoint: str
|
||||||
|
port: str
|
||||||
|
|
||||||
|
|
||||||
|
def format_static_peer(static_peer, routes, keepalive=30):
|
||||||
|
return f'''[Peer]
|
||||||
|
PublicKey = {static_peer.public_key}
|
||||||
|
AllowedIPs = {routes}
|
||||||
|
Endpoint = {static_peer.endpoint}:{static_peer.port}
|
||||||
|
PersistentKeepAlive = {keepalive}'''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("run")
|
print("run")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user