Skip to content

Commit

Permalink
routed: respect force direct dial context (#1665)
Browse files Browse the repository at this point in the history
* routed: respect force direct dial context

* Also fix holepunch debug logging params
  • Loading branch information
corverroos committed Aug 9, 2022
1 parent eb77ba4 commit 36422d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions p2p/host/routed/routed.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ func Wrap(h host.Host, r Routing) *RoutedHost {
// RoutedHost's Connect differs in that if the host has no addresses for a
// given peer, it will use its routing system to try to find some.
func (rh *RoutedHost) Connect(ctx context.Context, pi peer.AddrInfo) error {
// first, check if we're already connected.
if rh.Network().Connectedness(pi.ID) == network.Connected {
return nil
// first, check if we're already connected unless force direct dial.
forceDirect, _ := network.GetForceDirectDial(ctx)
if !forceDirect {
if rh.Network().Connectedness(pi.ID) == network.Connected {
return nil
}
}

// if we were given some addresses, keep + use them.
Expand Down
2 changes: 1 addition & 1 deletion p2p/protocol/holepunch/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (s *Service) handleNewStream(str network.Stream) {
rtt, addrs, err := s.incomingHolePunch(str)
if err != nil {
s.tracer.ProtocolError(rp, err)
log.Debugw("error handling holepunching stream from", rp, "error", err)
log.Debugw("error handling holepunching stream from", "peer", rp, "error", err)
str.Reset()
return
}
Expand Down

0 comments on commit 36422d5

Please sign in to comment.