From a02cb2bb43935c45a1d3914ed74197d2a85920a0 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 16 Mar 2023 14:03:31 +0100 Subject: [PATCH] Add a ping message to help wireguard initialize connections --- src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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")