diff options
| author | tv <tv@krebsco.de> | 2026-11-01 05:22:38 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-01 05:22:38 +0100 |
| commit | 9f8feeab71ccb864606c336097e20dbb8e1d8c86 (patch) | |
| tree | 5927a7cd59d97bad886c51d21d3f38739c862123 /src/transport/libp2p/mod.rs | |
| parent | 024458e67a4cb6f29bf1ff346c9f953781006129 (diff) | |
libp2p: autoignore unroutable address ranges
Diffstat (limited to 'src/transport/libp2p/mod.rs')
| -rw-r--r-- | src/transport/libp2p/mod.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/transport/libp2p/mod.rs b/src/transport/libp2p/mod.rs index 9d1dcc7..ace84c6 100644 --- a/src/transport/libp2p/mod.rs +++ b/src/transport/libp2p/mod.rs @@ -50,8 +50,12 @@ //! //! With `--libp2p-ignore`, address ranges are left out (VPNs): not published, not told //! peers by identify (`Identifying`), not offered for hole punching, not dialled, and -//! connections there refused (`Ignoring`). With `--libp2p-prefer`, addresses in the -//! ranges named come first, where only so many are kept (`Book::preference`). +//! connections there refused (`Ignoring`). Ranges this node has no route to are left +//! out alike, as long as it has none (`routes`): without IPv6 to the internet, peers' +//! public IPv6 addresses; and with `--libp2p-internet-hosts`, its own aren't published +//! then. With `--libp2p-prefer`, +//! addresses in the ranges named come first, where only so many are kept +//! (`Book::preference`). //! //! With `--libp2p-upnp`, a node asks its router to forward its listen ports (UPnP), and //! publishes the router's public address for them with its own (`Book::direct`): then @@ -101,6 +105,7 @@ mod driver; mod errors; mod ignore; mod relays; +mod routes; use behaviour::*; use book::*; @@ -109,6 +114,7 @@ use driver::*; use errors::*; use ignore::*; use relays::*; +use routes::*; /// The scheme of this transport's addresses (`transport::paths`). pub(crate) const SCHEME: &str = "libp2p"; @@ -251,6 +257,7 @@ impl Libp2pTransport { announced: config.announce, ignored: config.ignore.clone(), preferred: config.prefer.clone(), + routes: Routes::asking(config.internet_hosts.clone()), serving: config.relay, ..Book::default() }; @@ -288,13 +295,13 @@ impl Libp2pTransport { /// Connected to `peer`, if it can be had in time. async fn connect(&self, peer: PeerId) -> Result<()> { let addresses = { - let book = lock(&self.book); + let mut book = lock(&self.book); let mut known = book .addresses .get(&peer) .map(|known| dialable(known, self.peer_id)) .unwrap_or_default(); - known.retain(|address| !left_out(&book.ignored, address)); + known.retain(|address| !book.left_out(address)); if known.is_empty() { book.through_relays(peer, self.peer_id) } else { |
