From 76caaddbb2b1bdcce379ab2e301740e768f01b97 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Mon, 28 Jun 2021 21:05:44 +0200 Subject: [PATCH] wip --- bundles/wireguard/metadata.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/bundles/wireguard/metadata.py b/bundles/wireguard/metadata.py index dc01adb..4c22eb8 100644 --- a/bundles/wireguard/metadata.py +++ b/bundles/wireguard/metadata.py @@ -32,24 +32,28 @@ def systemd_networkd_networks(metadata): 'Address': { 'Address': metadata.get('wireguard/my_ip'), }, - 'Route': { - 'Destination': str(ip_interface(metadata.get('wireguard/my_ip')).network), - 'GatewayOnlink': 'yes', - }, 'Network': { 'DHCP': 'no', 'IPForward': 'yes', - 'IPMasquerade': 'yes', + #'IPMasquerade': 'yes', 'IPv6AcceptRA': 'no', }, } - for peer in metadata.get('wireguard/peers').values(): - for route in peer.get('route', []): + for peer, config in metadata.get('wireguard/peers').items(): + wg0.update({ + f'Route#{peer}': { + 'Destination': str(ip_interface(repo.get_node(peer).metadata.get(f'wireguard/my_ip')).ip), + 'Gateway': str(ip_interface(metadata.get('wireguard/my_ip')).ip), + 'GatewayOnlink': 'yes', + } + }) + for route in config.get('route', []): wg0.update({ - f'Route#{route}': { - 'Gateway': str(ip_interface(metadata.get('wireguard/my_ip')).ip), + f'Route#{peer}_{route}': { 'Destination': route, + 'Gateway': str(ip_interface(repo.get_node(peer).metadata.get(f'wireguard/my_ip')).ip), + 'GatewayOnlink': 'yes', } })