Skip to content

Commit

Permalink
identify: fix observed address handling
Browse files Browse the repository at this point in the history
If a connection was closed before receiving an identify response, the
corresponding observed address could be wrongly removed.

Patch by @sukunrt
  • Loading branch information
ivan4th committed Jun 7, 2024
1 parent 2769070 commit 441c0e1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions p2p/protocol/identify/obsaddr.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@ func (o *ObservedAddrManager) removeConn(conn connMultiaddrs) {
o.mu.Lock()
defer o.mu.Unlock()

observedTWAddr, ok := o.connObservedTWAddrs[conn]
if !ok {
return
}
delete(o.connObservedTWAddrs, conn)

// normalize before obtaining the thinWaist so that we are always dealing
// with the normalized form of the address
localTW, err := thinWaistForm(o.normalize(conn.LocalMultiaddr()))
Expand All @@ -467,11 +473,6 @@ func (o *ObservedAddrManager) removeConn(conn connMultiaddrs) {
delete(o.localAddrs, string(localTW.Addr.Bytes()))
}

observedTWAddr, ok := o.connObservedTWAddrs[conn]
if !ok {
return
}
delete(o.connObservedTWAddrs, conn)
observer, err := getObserver(conn.RemoteMultiaddr())
if err != nil {
return
Expand Down

0 comments on commit 441c0e1

Please sign in to comment.