diff options
author | Alex Auvolat <alex@adnab.me> | 2023-03-16 14:03:31 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-03-16 14:03:31 +0100 |
commit | a02cb2bb43935c45a1d3914ed74197d2a85920a0 (patch) | |
tree | 181f47913e8af2f0cd82d6920317df1b9baef568 /src | |
parent | c7dbb05be2440a067221c4cde41e341b4bc1fc57 (diff) | |
download | wgautomesh-a02cb2bb43935c45a1d3914ed74197d2a85920a0.tar.gz wgautomesh-a02cb2bb43935c45a1d3914ed74197d2a85920a0.zip |
Add a ping message to help wireguard initialize connections
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 6ced761..912d1cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -173,6 +173,8 @@ struct PeerInfo { #[derive(Serialize, Deserialize, Debug)] enum Gossip { + Ping, + Pong, Announce { pubkey: Pubkey, endpoints: Vec<(SocketAddr, u64)>, @@ -329,6 +331,11 @@ impl Daemon { } } } + Gossip::Ping => { + let packet = self.make_packet(&Gossip::Pong)?; + self.socket.send_to(&packet, from)?; + } + Gossip::Pong => (), } Ok(()) } @@ -666,6 +673,11 @@ impl State { &format!("{}/32", peer_cfg.address), ]) .output()?; + let packet = daemon.make_packet(&Gossip::Ping)?; + daemon.socket.send_to( + &packet, + SocketAddr::new(peer_cfg.address, daemon.config.gossip_port), + )?; } else { info!("Configure {} with no known endpoint", peer_cfg.pubkey); Command::new("wg") |