Stashing the function that inits routes on startup

in case we find out what was happening and it becomes useful again
This commit is contained in:
Erik Thuning 2025-03-26 16:28:48 +01:00
parent e5d1b9809e
commit 2a03b9b6c9

@ -181,6 +181,7 @@ class WireGuard:
# Ensure a wg config exists on startup
self.update(force=True)
self.init_routes()
def log(self, context_id: str, message) -> None:
@ -228,6 +229,14 @@ class WireGuard:
def meta_filepath(self, config_id: str) -> Path:
return self.filepath(f'{config_id}{metasuffix}')
def init_routes(self) -> None:
config = ConfigParser(interpolation=None)
for conffile in self.configs_base.glob('*/*'+serversuffix):
config.read(conffile)
client_ip_str = config['peer']['allowedips']
client_ip = ipaddress(client_ip_str.split('/')[0])
create_route(client_ip)
def generate_server_config(self):
config = ConfigParser(interpolation=None)
config['Interface'] = {