Skip to content

Commit b6ea099

Browse files
committed
fix: if we have private_neighbors = false, then don't bother selecting neighbors to walk to from there
1 parent cc8f86d commit b6ea099

File tree

1 file changed

+15
-1
lines changed
  • stackslib/src/net/neighbors

1 file changed

+15
-1
lines changed

stackslib/src/net/neighbors/db.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub trait NeighborWalkDB {
223223
e
224224
});
225225

226-
let mut next_neighbors = if let Ok(neighbors) = next_neighbors_res {
226+
let db_neighbors = if let Ok(neighbors) = next_neighbors_res {
227227
neighbors
228228
} else {
229229
let any_neighbors = Self::pick_walk_neighbors(network, (NUM_NEIGHBORS as u64) * 2, 0)
@@ -238,6 +238,20 @@ pub trait NeighborWalkDB {
238238

239239
any_neighbors
240240
};
241+
242+
let mut next_neighbors: Vec<_> = db_neighbors
243+
.into_iter()
244+
.filter_map(|neighbor| {
245+
if network.get_connection_opts().private_neighbors
246+
&& neighbor.addr.addrbytes.is_in_private_range()
247+
{
248+
None
249+
} else {
250+
Some(neighbor)
251+
}
252+
})
253+
.collect();
254+
241255
if next_neighbors.len() == 0 {
242256
return Err(net_error::NoSuchNeighbor);
243257
}

0 commit comments

Comments
 (0)