Skip to content

Commit

Permalink
feat(holepunch): add logging when DirectConnect execution fails (#3146)
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Munizaga <[email protected]>
  • Loading branch information
wlynxg and MarcoPolo authored Feb 3, 2025
1 parent 9584246 commit 8deaed7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions p2p/protocol/holepunch/holepuncher.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ func (hp *holePuncher) directConnect(rp peer.ID) error {
for i := 1; i <= maxRetries; i++ {
addrs, obsAddrs, rtt, err := hp.initiateHolePunch(rp)
if err != nil {
log.Debugw("hole punching failed", "peer", rp, "error", err)
hp.tracer.ProtocolError(rp, err)
return err
}
Expand Down Expand Up @@ -184,9 +183,8 @@ func (hp *holePuncher) initiateHolePunch(rp peer.ID) ([]ma.Multiaddr, []ma.Multi

addr, obsAddr, rtt, err := hp.initiateHolePunchImpl(str)
if err != nil {
log.Debugf("%s", err)
str.Reset()
return addr, obsAddr, rtt, err
return addr, obsAddr, rtt, fmt.Errorf("failed to initiateHolePunch: %w", err)
}
return addr, obsAddr, rtt, err
}
Expand Down Expand Up @@ -278,7 +276,10 @@ func (nn *netNotifiee) Connected(_ network.Network, conn network.Conn) {
return
}

_ = hs.DirectConnect(conn.RemotePeer())
err := hs.DirectConnect(conn.RemotePeer())
if err != nil {
log.Debugf("attempt to perform DirectConnect to %s failed: %s", conn.RemotePeer(), err)
}
}()
}
}
Expand Down

0 comments on commit 8deaed7

Please sign in to comment.