Skip to content

Commit

Permalink
fix(swarm): check after we split for empty multiaddr (#3063)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo authored Nov 26, 2024
1 parent 666d1ed commit 27bbad1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions p2p/net/swarm/swarm_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
// TransportForDialing retrieves the appropriate transport for dialing the given
// multiaddr.
func (s *Swarm) TransportForDialing(a ma.Multiaddr) transport.Transport {
if a == nil {
return nil
}
protocols := a.Protocols()
if len(protocols) == 0 {
return nil
Expand All @@ -34,6 +37,9 @@ func (s *Swarm) TransportForDialing(a ma.Multiaddr) transport.Transport {
if id, _ := peer.IDFromP2PAddr(a); id != "" {
// This addr has a p2p component. Drop it so we can check transport.
a, _ = ma.SplitLast(a)
if a == nil {
return nil
}
}
for _, t := range s.transports.m {
if t.CanDial(a) {
Expand Down

0 comments on commit 27bbad1

Please sign in to comment.