Skip to content

Commit

Permalink
fix(identify): do not add p2p and relayed addrs to observed addr mana…
Browse files Browse the repository at this point in the history
…ger (#990)
  • Loading branch information
diegomrsantos authored and dryajov committed Dec 4, 2023
1 parent 7286684 commit a87cc1a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libp2p/protocols/identify.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import ../protobuf/minprotobuf,
../peerid,
../crypto/crypto,
../multiaddress,
../multicodec,
../protocols/protocol,
../utility,
../errors,
Expand Down Expand Up @@ -187,8 +188,12 @@ proc identify*(self: Identify,
info.peerId = peer

info.observedAddr.withValue(observed):
if not self.observedAddrManager.addObservation(observed):
debug "Observed address is not valid", observedAddr = observed
# Currently, we use the ObservedAddrManager only to find our dialable external NAT address. Therefore, addresses
# like "...\p2p-circuit\p2p\..." and "\p2p\..." are not useful to us.
if observed.contains(multiCodec("p2p-circuit")).get(false) or P2PPattern.matchPartial(observed):
trace "Not adding address to ObservedAddrManager.", observed
elif not self.observedAddrManager.addObservation(observed):
trace "Observed address is not valid.", observedAddr = observed
return info

proc new*(T: typedesc[IdentifyPush], handler: IdentifyPushHandler = nil): T {.public.} =
Expand Down

0 comments on commit a87cc1a

Please sign in to comment.