Skip to content

Commit bcbf7a5

Browse files
committed
identify: only record observed addresses that match an address we're announcing
This is should prevent us from, e.g., announcing relay addresses _just_ because a peer tells us we're reachable through a relay.
1 parent 544c412 commit bcbf7a5

File tree

1 file changed

+10
-0
lines changed
  • p2p/protocol/identify

1 file changed

+10
-0
lines changed

p2p/protocol/identify/id.go

+10
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ func (ids *IDService) consumeMessage(mes *pb.Identify, c inet.Conn) {
240240

241241
// NOTE: Do not add `c.RemoteMultiaddr()` to the peerstore if the remote
242242
// peer doesn't tell us to do so. Otherwise, we'll advertise it.
243+
//
244+
// This can cause an "addr-splosion" issue where the network will slowly
245+
// gossip and collect observed but unadvertised addresses. Given a NAT
246+
// that picks random source ports, this can cause DHT nodes to collect
247+
// many undialable addresses for other peers.
243248

244249
// Extend the TTLs on the known (probably) good addresses.
245250
// Taking the lock ensures that we don't concurrently process a disconnect.
@@ -415,6 +420,11 @@ func (ids *IDService) consumeObservedAddress(observed []byte, c inet.Conn) {
415420
return
416421
}
417422

423+
if !HasConsistentTransport(maddr, ids.Host.Addrs()) {
424+
log.Debugf("ignoring observed multiaddr that doesn't match the transports of any addresses we're announcing", c.RemoteMultiaddr())
425+
return
426+
}
427+
418428
// ok! we have the observed version of one of our ListenAddresses!
419429
log.Debugf("added own observed listen addr: %s --> %s", c.LocalMultiaddr(), maddr)
420430
ids.observedAddrs.Add(maddr, c.LocalMultiaddr(), c.RemoteMultiaddr(),

0 commit comments

Comments
 (0)