Add rm command and misc fixes
This commit is contained in:
parent
7e3953ad46
commit
f619c3cf04
15
woven.py
15
woven.py
|
@ -48,6 +48,10 @@ def generate_wg_configs(config: WovenConfig):
|
|||
except NetmaskValueError:
|
||||
raise ValueError("invalid IPv6 PtP network subnet")
|
||||
|
||||
cs = { id: Connection(node.listen_address, user = "root") for id, node in config.nodes.items() }
|
||||
for c in cs.values():
|
||||
c.run(f"rm /etc/wireguard/*-loop.conf")
|
||||
|
||||
ptp_ipv4_network_iter = ptp_ipv4_network.subnets(new_prefix = config.ptp_ipv4_subnet)
|
||||
ptp_ipv6_network_iter = ptp_ipv6_network.subnets(new_prefix = config.ptp_ipv6_subnet)
|
||||
port_iter = iter(range(config.min_port, config.max_port))
|
||||
|
@ -91,7 +95,7 @@ def generate_wg_configs(config: WovenConfig):
|
|||
listen_port = port,
|
||||
private_key = key_a,
|
||||
preup=[f"ip ro add {node_b.listen_address}/32 dev {node_a.interface_name} via {node_a.listen_gateway} metric 10 src {node_a.listen_address}"],
|
||||
predown=[f"ip ro add {node_b.listen_address}/32 dev {node_a.interface_name} via {node_a.listen_gateway} metric 10 src {node_a.listen_address}"],
|
||||
predown=[f"ip ro del {node_b.listen_address}/32 dev {node_a.interface_name} via {node_a.listen_gateway} metric 10 src {node_a.listen_address}"],
|
||||
peers = {
|
||||
key_b_pub: WireguardPeer(
|
||||
public_key = key_b_pub,
|
||||
|
@ -108,7 +112,7 @@ def generate_wg_configs(config: WovenConfig):
|
|||
listen_port = port,
|
||||
private_key = key_b,
|
||||
preup=[f"ip ro add {node_a.listen_address}/32 dev {node_b.interface_name} via {node_b.listen_gateway} metric 10 src {node_b.listen_address}"],
|
||||
predown=[f"ip ro add {node_a.listen_address}/32 dev {node_b.interface_name} via {node_b.listen_gateway} metric 10 src {node_b.listen_address}"],
|
||||
predown=[f"ip ro del {node_a.listen_address}/32 dev {node_b.interface_name} via {node_b.listen_gateway} metric 10 src {node_b.listen_address}"],
|
||||
peers = {
|
||||
key_a_pub: WireguardPeer(
|
||||
public_key = key_a_pub,
|
||||
|
@ -120,11 +124,8 @@ def generate_wg_configs(config: WovenConfig):
|
|||
}
|
||||
)
|
||||
|
||||
c_a = Connection(node_a.listen_address, user = "root")
|
||||
c_a.put(StringIO(config_a.to_wgconfig(wgquick_format = True)), str(Path("/") / "etc" / "wireguard" / f"{id_a}-{id_b}-loop.conf"))
|
||||
|
||||
c_b = Connection(node_b.listen_address, user = "root")
|
||||
c_b.put(StringIO(config_b.to_wgconfig(wgquick_format = True)), str(Path("/") / "etc" / "wireguard" / f"{id_b}-{id_a}-loop.conf"))
|
||||
cs[id_a].put(StringIO(config_a.to_wgconfig(wgquick_format = True)), f"/etc/wireguard/{id_a}-{id_b}-loop.conf")
|
||||
cs[id_b].put(StringIO(config_b.to_wgconfig(wgquick_format = True)), f"/etc/wireguard/{id_b}-{id_a}-loop.conf")
|
||||
|
||||
def main():
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue