Remove ip subnets from postup rules

This commit is contained in:
LilyRose2798 2024-04-17 01:44:32 +10:00
parent fc228fd4dd
commit 32272650da
1 changed files with 8 additions and 8 deletions

View File

@ -73,15 +73,15 @@ def generate_wg_configs(config: WovenConfig):
ipv4_iter = ptp_ipv4_network.hosts() ipv4_iter = ptp_ipv4_network.hosts()
try: try:
ipv4_a = IPv4Interface(f"{next(ipv4_iter)}/{ptp_ipv4_network.prefixlen}") ipv4_a = next(ipv4_iter)
ipv4_b = IPv4Interface(f"{next(ipv4_iter)}/{ptp_ipv4_network.prefixlen}") ipv4_b = next(ipv4_iter)
except StopIteration: except StopIteration:
raise ValueError("not enough IPv4 addresses in each PtP network") raise ValueError("not enough IPv4 addresses in each PtP network")
ipv6_iter = ptp_ipv6_network.hosts() ipv6_iter = ptp_ipv6_network.hosts()
try: try:
ipv6_a = IPv6Interface(f"{next(ipv6_iter)}/{ptp_ipv6_network.prefixlen}") ipv6_a = next(ipv6_iter)
ipv6_b = IPv6Interface(f"{next(ipv6_iter)}/{ptp_ipv6_network.prefixlen}") ipv6_b = next(ipv6_iter)
except StopIteration: except StopIteration:
raise ValueError("not enough IPv6 addresses in each PtP network") raise ValueError("not enough IPv6 addresses in each PtP network")
@ -95,7 +95,7 @@ def generate_wg_configs(config: WovenConfig):
name_b = f"{id_b}-{id_a}-loop" name_b = f"{id_b}-{id_a}-loop"
config_a = WireguardConfig( config_a = WireguardConfig(
addresses = [ipv4_a, ipv6_a], addresses = [IPv4Interface(f"{ipv4_a}/{ptp_ipv4_network.prefixlen}"), IPv6Interface(f"{ipv6_a}/{ptp_ipv6_network.prefixlen}")],
listen_port = port, listen_port = port,
private_key = key_a, private_key = key_a,
table = False, table = False,
@ -117,7 +117,7 @@ def generate_wg_configs(config: WovenConfig):
) )
config_b = WireguardConfig( config_b = WireguardConfig(
addresses = [ipv4_b, ipv6_b], addresses = [IPv4Interface(f"{ipv4_b}/{ptp_ipv4_network.prefixlen}"), IPv6Interface(f"{ipv6_b}/{ptp_ipv6_network.prefixlen}")],
listen_port = port, listen_port = port,
private_key = key_b, private_key = key_b,
table = False, table = False,
@ -140,10 +140,10 @@ def generate_wg_configs(config: WovenConfig):
cs[id_a].put(StringIO(config_a.to_wgconfig(wgquick_format = True)), f"/etc/wireguard/{name_a}.conf") cs[id_a].put(StringIO(config_a.to_wgconfig(wgquick_format = True)), f"/etc/wireguard/{name_a}.conf")
# cs[id_a].run(f"systemctl start wg-quick@{name_a}.service") cs[id_a].run(f"systemctl start wg-quick@{name_a}.service")
cs[id_b].put(StringIO(config_b.to_wgconfig(wgquick_format = True)), f"/etc/wireguard/{name_b}.conf") cs[id_b].put(StringIO(config_b.to_wgconfig(wgquick_format = True)), f"/etc/wireguard/{name_b}.conf")
# cs[id_b].run(f"systemctl start wg-quick@{name_b}.service") cs[id_b].run(f"systemctl start wg-quick@{name_b}.service")
def main(): def main():