File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 24
24
IP6Unspecified = ma .StringCast ("/ip6/::" )
25
25
)
26
26
27
+ // Loopback multiaddr prefixes. Any multiaddr beginning with one of the
28
+ // following byte sequences is considered a loopback multiaddr.
29
+ var loopbackPrefixes = [][]byte {
30
+ {ma .P_IP4 , 127 }, // 127.*
31
+ IP6LinkLocalLoopback .Bytes (),
32
+ IP6Loopback .Bytes (),
33
+ }
34
+
27
35
// IsThinWaist returns whether a Multiaddr starts with "Thin Waist" Protocols.
28
36
// This means: /{IP4, IP6}[/{TCP, UDP}]
29
37
func IsThinWaist (m ma.Multiaddr ) bool {
@@ -51,17 +59,11 @@ func IsThinWaist(m ma.Multiaddr) bool {
51
59
}
52
60
}
53
61
54
- var localPrefixes = [][]byte {
55
- {ma .P_IP4 , 127 }, // 127.*
56
- IP6LinkLocalLoopback .Bytes (),
57
- IP6Loopback .Bytes (),
58
- }
59
-
60
62
// IsIPLoopback returns whether a Multiaddr is a "Loopback" IP address
61
63
// This means either /ip4/127.*.*.*, /ip6/::1, or /ip6/fe80::1
62
64
func IsIPLoopback (m ma.Multiaddr ) bool {
63
65
b := m .Bytes ()
64
- for _ , prefix := range localPrefixes {
66
+ for _ , prefix := range loopbackPrefixes {
65
67
if bytes .HasPrefix (b , prefix ) {
66
68
return true
67
69
}
You can’t perform that action at this time.
0 commit comments