From cb03ba5556ea4992d2f20e95c4aee949efb515c2 Mon Sep 17 00:00:00 2001 From: lare Date: Sat, 22 Apr 2023 15:59:08 +0200 Subject: [PATCH] [node] use ipv4 or ipv6 if no ipv6 ll is specified --- nodes/main.py | 6 ++++-- nodes/templates/bgp-peer.template.conf | 6 +++--- nodes/templates/wireguard.template.conf | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nodes/main.py b/nodes/main.py index 255b53f..841a247 100644 --- a/nodes/main.py +++ b/nodes/main.py @@ -239,8 +239,10 @@ class PeeringManager: for pNr in range(len(self.peerings[asn])): if self.peerings[asn][pNr]["node"] == node: old_peering = self.peerings[asn][pNr] - new_peering = self.peerings[asn][pNr] = {"MNT": MNT if MNT!=NotSpecified else old_peering["MNT"], "ASN": asn, "node": config["nodename"], "wg_key": wg_key, - "endpoint": endpoint if endpoint!=NotSpecified else old_peering["endpoint"], "ipv6ll": ipv6ll if ipv6ll != NotSpecified else old_peering["ipv6ll"], "ipv4": ipv4 if ipv4 != NotSpecified else old_peering["ipv4"], "ipv6": ipv6 if ipv6 != NotSpecified else old_peering["ipv6"], "bgp_mp": bgp_mp if bgp_mp != NotSpecified else old_peering["bgp_mp"], "bgp_enh": bgp_enh if bgp_enh != NotSpecified else old_peering["bgp_enh"]} + new_peering = self.peerings[asn][pNr] = {"MNT": MNT if MNT!=NotSpecified else old_peering["MNT"], "ASN": asn, "node": config["nodename"], + "wg_key": wg_key,"endpoint": endpoint if endpoint!=NotSpecified else old_peering["endpoint"], + "ipv6ll": ipv6ll if ipv6ll != NotSpecified else old_peering["ipv6ll"], "ipv4": ipv4 if ipv4 != NotSpecified else old_peering["ipv4"], "ipv6": ipv6 if ipv6 != NotSpecified else old_peering["ipv6"], + "bgp_mp": bgp_mp if bgp_mp != NotSpecified else old_peering["bgp_mp"], "bgp_enh": bgp_enh if bgp_enh != NotSpecified else old_peering["bgp_enh"]} success = True if not success: return False, 404 diff --git a/nodes/templates/bgp-peer.template.conf b/nodes/templates/bgp-peer.template.conf index eb0c77a..f8c6df4 100644 --- a/nodes/templates/bgp-peer.template.conf +++ b/nodes/templates/bgp-peer.template.conf @@ -1,6 +1,6 @@ -{% if peering["bgp_mp"] %} +{% if peering["bgp_mp"] == True %} protocol bgp dn42_{{peering["MNT"][:-4].lower()}}_{{peering["ASN"][-4:]}} from dnpeers { - neighbor {{peering["ipv6ll"]}} as {{peering["ASN"]}}; + neighbor {{peering["ipv6ll"] or peering["ipv4"] or peering["ipv6"]}} as {{peering["ASN"]}}; interface {% if peering['ASN'].__len__() >=6 %}"dn42_{{peering['ASN'][-6:]}}"{% else %}"dn42_{{peering['asn']}}"{% endif %}; passive off; @@ -19,7 +19,7 @@ protocol bgp dn42_{{peering["MNT"][:-4].lower()}}_{{peering["ASN"][-4:]}} from d extended next hop {% if peering["bgp_enh"] %}on{%else%}off{%endif%}; }; }; -{%else%} +{% elif peering["bgp_mp"] == False %} protocol bgp dn42_{{peering["MNT"][:-4].lower()}}_{{peering['ASN'][-4:]}}_4 from dnpeers { neighbor {{peering["ipv4"]}} as {{peering["ASN"]}}; passive off; diff --git a/nodes/templates/wireguard.template.conf b/nodes/templates/wireguard.template.conf index fae0ed7..ee31072 100644 --- a/nodes/templates/wireguard.template.conf +++ b/nodes/templates/wireguard.template.conf @@ -2,7 +2,7 @@ PostUp = wg set %i private-key /etc/wireguard/dn42.priv ListenPort = 2{{peering["ASN"][-4:]}} {% if peering["ipv4"] %}PostUp = /sbin/ip addr add dev %i 172.22.125.130/32 peer {{peering["ipv4"]}}/32 -{%endif%}{% if peering["ipv6"] %}PostUp = /sbin/ip addr add dev %i fe63:5d40:47e5::130/128 peer {{peering["ipv6"]}}/128 +{%endif%}{% if peering["ipv6"] %}PostUp = /sbin/ip addr add dev %i fd63:5d40:47e5::130/128 peer {{peering["ipv6"]}}/128 {%endif%}{% if peering["ipv6ll"] %}PostUp = /sbin/ip addr add dev %i fe80::3035:130/128 peer {{peering["ipv6ll"]}}/128{%endif%} Table = off