Commit c52f4523 authored by vyzo's avatar vyzo
Browse files

simplify routed relay addr check

the first component must be P_P2P, or else we have a specific address to dial
parent dd9b96f7
...@@ -68,8 +68,8 @@ func (rh *RoutedHost) Connect(ctx context.Context, pi pstore.PeerInfo) error { ...@@ -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 // Issue 448: if our address set includes routed specific relay addrs,
// to make sure the relay's addr itself is in the peerstore or else // we need to make sure the relay's addr itself is in the peerstore or else
// we wont be able to dial it. // we wont be able to dial it.
for _, addr := range addrs { for _, addr := range addrs {
_, err := addr.ValueForProtocol(circuit.P_CIRCUIT) _, err := addr.ValueForProtocol(circuit.P_CIRCUIT)
...@@ -78,23 +78,19 @@ func (rh *RoutedHost) Connect(ctx context.Context, pi pstore.PeerInfo) error { ...@@ -78,23 +78,19 @@ func (rh *RoutedHost) Connect(ctx context.Context, pi pstore.PeerInfo) error {
continue continue
} }
relay, err := addr.ValueForProtocol(ma.P_P2P) if addr.Protocols()[0].Code != ma.P_P2P {
if err != nil { // not a routed relay specific address
// not a specific relay address
continue continue
} }
relay, _ := addr.ValueForProtocol(ma.P_P2P)
relayID, err := peer.IDFromString(relay) relayID, err := peer.IDFromString(relay)
if err != nil { if err != nil {
log.Debugf("failed to parse relay ID in address %s: %s", relay, err) log.Debugf("failed to parse relay ID in address %s: %s", relay, err)
continue 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 { if len(rh.Peerstore().Addrs(relayID)) > 0 {
// we already have addrs for this relay // we already have addrs for this relay
continue continue
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment