summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2025-12-16 04:21:57 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2025-12-16 04:21:57 -0800
commit938a3be60a5f5c23687c7b24258534e6a8d986e5 (patch)
treeb54d72e47a6ca6d9360b91be9bed0f3aab226530
parenta23ca3aeae75ab9b7e90280c222882961a916a70 (diff)
downloadwg-genconf-938a3be60a5f5c23687c7b24258534e6a8d986e5.tar.gz
wg-genconf-938a3be60a5f5c23687c7b24258534e6a8d986e5.tar.xz
support PersistentKeepalive
-rwxr-xr-xwg-genconf.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/wg-genconf.py b/wg-genconf.py
index b56347a..bcc7efe 100755
--- a/wg-genconf.py
+++ b/wg-genconf.py
@@ -55,6 +55,7 @@ class Interface(collections.UserDict):
_INHERITABLE = [
'port',
'fwmark',
+ 'keepalive',
'file-prefix',
'name-format',
@@ -174,6 +175,8 @@ def gc_if_data(if_):
'pubkey': peer['pubkey'],
'ips': ipspecs_to_ips(peer, peerspec.get('ips', ['{peer}'])),
'endpoint': None,
+ 'keepalive': (peerspec['keepalive'] if 'keepalive' in peerspec else
+ if_.get('keepalive')),
}
if (host := peer.get('host')):
peer_data['endpoint'] = f'{host}:{peer.get('port', 51820)}'
@@ -203,6 +206,8 @@ def gc_if_wgquick(if_data):
buf.write(f'AllowedIPs = {ip}\n')
if (endpoint := peer_data.get('endpoint')):
buf.write(f'Endpoint = {endpoint}\n')
+ if (keepalive := peer_data.get('keepalive')):
+ buf.write(f'PersistentKeepalive = {keepalive}\n')
return buf
@@ -244,6 +249,8 @@ def gc_if_systemd_netdev(if_data):
buf.write(f'AllowedIPs={ip}\n')
if (endpoint := peer_data.get('endpoint')):
buf.write(f'Endpoint={endpoint}\n')
+ if (keepalive := peer_data.get('keepalive')):
+ buf.write(f'PersistentKeepalive={keepalive}\n')
return buf