Skip to content

Commit

Permalink
(feat) Allow whitelisted local addresses, so that local z2 networks c…
Browse files Browse the repository at this point in the history
…an communicate
  • Loading branch information
rrw-zilliqa committed Nov 19, 2024
1 parent 1e60216 commit 000f035
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion zilliqa/src/p2p_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::{
collections::HashMap,
iter,
ops::BitAnd,
sync::{atomic::AtomicUsize, Arc},
time::Duration,
};
Expand Down Expand Up @@ -252,7 +253,17 @@ impl P2pNode {
for addr in listen_addrs {
// If the node is advertising a non-global address, ignore it.
let is_non_global = addr.iter().any(|p| match p {
Protocol::Ip4(addr) => addr.is_loopback() || addr.is_private(),
Protocol::Ip4(addr) => {
if let Some((net, mask)) = self.config.listening_subnet {
let left = net.bitand(mask);
let right = addr.bitand(mask);
if left == right {
info!("p2p_identify: {addr:?} is in the listening subnet - passing");
return false;
}
}
addr.is_loopback() || addr.is_private()
},
Protocol::Ip6(addr) => addr.is_loopback(),
_ => false,
});
Expand Down

0 comments on commit 000f035

Please sign in to comment.