@@ -55,19 +55,15 @@ func IsThinWaist(m ma.Multiaddr) bool {
55
55
}
56
56
}
57
57
58
- // IsIPLoopback returns whether a Multiaddr is a "Loopback" IP address
59
- // This means either /ip4/127.*.*.*, /ip6/::1, or /ip6/::ffff:127.*.*.*.*,
60
- // or /ip6zone/<any value>/ip6/<one of the preceding ip6 values>
58
+ // IsIPLoopback returns whether a Multiaddr starts with a "Loopback" IP address
59
+ // This means either /ip4/127.*.*.*/* , /ip6/::1/* , or /ip6/::ffff:127.*.*.*.*/ *,
60
+ // or /ip6zone/<any value>/ip6/<one of the preceding ip6 values>/*
61
61
func IsIPLoopback (m ma.Multiaddr ) bool {
62
62
m = zoneless (m )
63
- c , rest := ma .SplitFirst (m )
63
+ c , _ := ma .SplitFirst (m )
64
64
if c == nil {
65
65
return false
66
66
}
67
- if rest != nil {
68
- // Not *just* an IPv4 addr
69
- return false
70
- }
71
67
switch c .Protocol ().Code {
72
68
case ma .P_IP4 , ma .P_IP6 :
73
69
return net .IP (c .RawValue ()).IsLoopback ()
@@ -88,14 +84,15 @@ func IsIP6LinkLocal(m ma.Multiaddr) bool {
88
84
return ip .IsLinkLocalMulticast () || ip .IsLinkLocalUnicast ()
89
85
}
90
86
91
- // IsIPUnspecified returns whether a Multiaddr is am Unspecified IP address
92
- // This means either /ip4/0.0.0.0 or /ip6/::
87
+ // IsIPUnspecified returns whether a Multiaddr starts with an Unspecified IP address
88
+ // This means either /ip4/0.0.0.0/* or /ip6/::/*
93
89
func IsIPUnspecified (m ma.Multiaddr ) bool {
94
90
m = zoneless (m )
95
91
if m == nil {
96
92
return false
97
93
}
98
- return IP4Unspecified .Equal (m ) || IP6Unspecified .Equal (m )
94
+ c , _ := ma .SplitFirst (m )
95
+ return net .IP (c .RawValue ()).IsUnspecified ()
99
96
}
100
97
101
98
// If m matches [zone,ip6,...], return [ip6,...]
0 commit comments