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.
@@ -240,6 +240,11 @@ func (ids *IDService) consumeMessage(mes *pb.Identify, c inet.Conn) {
// NOTE: Do not add `c.RemoteMultiaddr()` to the peerstore if the remote
// peer doesn't tell us to do so. Otherwise, we'll advertise it.
+ //
+ // This can cause an "addr-splosion" issue where the network will slowly
+ // gossip and collect observed but unadvertised addresses. Given a NAT
+ // that picks random source ports, this can cause DHT nodes to collect
+ // many undialable addresses for other peers.
// Extend the TTLs on the known (probably) good addresses.
// 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) {
return
}
+ if !HasConsistentTransport(maddr, ids.Host.Addrs()) {
+ log.Debugf("ignoring observed multiaddr that doesn't match the transports of any addresses we're announcing", c.RemoteMultiaddr())
+ return
+ }
+
// ok! we have the observed version of one of our ListenAddresses!
log.Debugf("added own observed listen addr: %s --> %s", c.LocalMultiaddr(), maddr)
ids.observedAddrs.Add(maddr, c.LocalMultiaddr(), c.RemoteMultiaddr(),
