Add a ping message to help wireguard initialize connections

This commit is contained in:
Alex 2023-03-16 14:03:31 +01:00
parent c7dbb05be2
commit a02cb2bb43
1 changed files with 12 additions and 0 deletions

View File

@ -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")