Skip to content

Commit

Permalink
fix: prevent node info zero address
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Aug 18, 2023
1 parent efab153 commit 4a4223e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/net/network/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,17 @@ impl PeersInfo for NetworkHandle {

fn local_node_record(&self) -> NodeRecord {
let id = *self.peer_id();
let socket_addr = *self.inner.listener_address.lock();
let mut socket_addr = *self.inner.listener_address.lock();

if socket_addr.ip().is_unspecified() {
// zero address is invalid
if socket_addr.ip().is_ipv4() {
socket_addr.set_ip(std::net::IpAddr::V4(std::net::Ipv4Addr::LOCALHOST));
} else {
socket_addr.set_ip(std::net::IpAddr::V6(std::net::Ipv6Addr::LOCALHOST));
}
}

NodeRecord::new(socket_addr, id)
}
}
Expand Down

0 comments on commit 4a4223e

Please sign in to comment.