For mapped ipv4 add plain ip4 to known addresses

This commit is contained in:
Dennis Schwerdel 2020-05-28 08:57:25 +02:00
parent 74b86ff3ef
commit 7b79b9b26f
1 changed files with 9 additions and 1 deletions

View File

@ -114,10 +114,18 @@ impl<TS: TimeSource> PeerList<TS> {
fn add(&mut self, node_id: NodeId, addr: SocketAddr, peer_timeout: u16) { fn add(&mut self, node_id: NodeId, addr: SocketAddr, peer_timeout: u16) {
if self.nodes.insert(node_id, addr).is_none() { if self.nodes.insert(node_id, addr).is_none() {
info!("New peer: {}", addr); info!("New peer: {}", addr);
let mut alt_addrs = vec![];
if let SocketAddr::V6(v6_addr) = addr {
if let Some(ipv4) = v6_addr.ip().to_ipv4() {
let v4_addr = SocketAddr::from((ipv4, v6_addr.port()));
alt_addrs.push(v4_addr);
self.addresses.insert(v4_addr, node_id);
}
}
self.peers.insert(addr, PeerData { self.peers.insert(addr, PeerData {
timeout: TS::now() + Time::from(self.timeout), timeout: TS::now() + Time::from(self.timeout),
node_id, node_id,
alt_addrs: vec![], alt_addrs,
peer_timeout peer_timeout
}); });
self.addresses.insert(addr, node_id); self.addresses.insert(addr, node_id);