From c52f45235d1b2a27d220c0e7944ea2b0c2489037 Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 8 Oct 2018 15:04:43 +0300 Subject: [PATCH] simplify routed relay addr check the first component must be P_P2P, or else we have a specific address to dial --- p2p/host/routed/routed.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/p2p/host/routed/routed.go b/p2p/host/routed/routed.go index 5435bcd..97b58a9 100644 --- a/p2p/host/routed/routed.go +++ b/p2p/host/routed/routed.go @@ -68,8 +68,8 @@ func (rh *RoutedHost) Connect(ctx context.Context, pi pstore.PeerInfo) error { } } - // Issue 448: if our address set includes specific relay addrs, we need - // to make sure the relay's addr itself is in the peerstore or else + // Issue 448: if our address set includes routed specific relay addrs, + // we need to make sure the relay's addr itself is in the peerstore or else // we wont be able to dial it. for _, addr := range addrs { _, err := addr.ValueForProtocol(circuit.P_CIRCUIT) @@ -78,23 +78,19 @@ func (rh *RoutedHost) Connect(ctx context.Context, pi pstore.PeerInfo) error { continue } - relay, err := addr.ValueForProtocol(ma.P_P2P) - if err != nil { - // not a specific relay address + if addr.Protocols()[0].Code != ma.P_P2P { + // not a routed relay specific address continue } + relay, _ := addr.ValueForProtocol(ma.P_P2P) + relayID, err := peer.IDFromString(relay) if err != nil { log.Debugf("failed to parse relay ID in address %s: %s", relay, err) continue } - if relayID == pi.ID { - // it's an old style p2p-circuit address that includes the peer - continue - } - if len(rh.Peerstore().Addrs(relayID)) > 0 { // we already have addrs for this relay continue -- GitLab