This commit is contained in:
mwiegand 2021-10-10 14:55:57 +02:00
parent 316d7db89d
commit d87c77b441
6 changed files with 16 additions and 18 deletions

View file

@ -13,7 +13,7 @@ data = server_node.metadata.get(f'wireguard/clients/{argv[1]}')
sortable_client_routes = [
ip_interface(server_node.metadata.get('network/internal/ipv4')).network,
]
for peer in server_node.metadata.get('wireguard/peers').values():
for peer in server_node.metadata.get('wireguard/s2s').values():
for network in peer.get('route'):
sortable_client_routes.append(ip_network(network))

View file

@ -18,28 +18,28 @@ defaults = {
},
},
'wireguard': {
'peers': {},
's2s': {},
'clients': {},
},
}
@metadata_reactor.provides(
'wireguard/peers',
'wireguard/s2s',
)
def s2s_peer_specific(metadata):
return {
'wireguard': {
'peers': {
peer: {
'id': repo.get_node(peer).metadata.get(f'id'),
'ip': repo.get_node(peer).metadata.get(f'wireguard/my_ip'),
'endpoint': f'{repo.get_node(peer).hostname}:51820',
's2s': {
s2s: {
'id': repo.get_node(s2s).metadata.get(f'id'),
'ip': repo.get_node(s2s).metadata.get(f'wireguard/my_ip'),
'endpoint': f'{repo.get_node(s2s).hostname}:51820',
'route': [
str(ip_interface(repo.get_node(peer).metadata.get(f'wireguard/my_ip')).network),
str(ip_interface(repo.get_node(s2s).metadata.get(f'wireguard/my_ip')).network),
],
}
for peer in metadata.get('wireguard/peers')
for s2s in metadata.get('wireguard/s2s')
},
},
}
@ -82,9 +82,7 @@ def systemd_networkd_networks(metadata):
},
}
for peer, config in {
**metadata.get('wireguard/peers'),
}.items():
for peer, config in metadata.get('wireguard/s2s').items():
for route in config.get('route', []):
network.update({
f'Route#{peer}_{route}': {
@ -119,7 +117,7 @@ def systemd_networkd_netdevs(metadata):
}
for peer, config in {
**metadata.get('wireguard/peers'),
**metadata.get('wireguard/s2s'),
**metadata.get('wireguard/clients'),
}.items():
netdev.update({

View file

@ -59,7 +59,7 @@
},
'wireguard': {
'my_ip': '172.30.0.2/32',
'peers': {
's2s': {
'htz.mails': {
'route': [
'10.0.10.0/24',

View file

@ -141,7 +141,7 @@
},
'wireguard': {
'my_ip': '172.30.0.1/24',
'peers': {
's2s': {
'home.server': {
'route': [
'10.0.0.0/24',

View file

@ -32,7 +32,7 @@
# },
'wireguard': {
'my_ip': '172.30.0.3/32',
'peers': {
's2s': {
'htz.mails': {
'route': [
'10.0.0.0/24',

View file

@ -23,7 +23,7 @@
},
'wireguard': {
'my_ip': '172.30.0.4/32',
'peers': {
's2s': {
'htz.mails': {
'route': [
'10.0.0.0/24',