Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mf
go-multiaddr
Commits
ef7ebf9d
Commit
ef7ebf9d
authored
Mar 08, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename, comment, and move loopback prefixes
Helps readers understand what they're looking at.
parent
d1762038
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
ip.go
ip.go
+9
-7
No files found.
ip.go
View file @
ef7ebf9d
...
...
@@ -24,6 +24,14 @@ var (
IP6Unspecified
=
ma
.
StringCast
(
"/ip6/::"
)
)
// Loopback multiaddr prefixes. Any multiaddr beginning with one of the
// following byte sequences is considered a loopback multiaddr.
var
loopbackPrefixes
=
[][]
byte
{
{
ma
.
P_IP4
,
127
},
// 127.*
IP6LinkLocalLoopback
.
Bytes
(),
IP6Loopback
.
Bytes
(),
}
// IsThinWaist returns whether a Multiaddr starts with "Thin Waist" Protocols.
// This means: /{IP4, IP6}[/{TCP, UDP}]
func
IsThinWaist
(
m
ma
.
Multiaddr
)
bool
{
...
...
@@ -51,17 +59,11 @@ func IsThinWaist(m ma.Multiaddr) bool {
}
}
var
localPrefixes
=
[][]
byte
{
{
ma
.
P_IP4
,
127
},
// 127.*
IP6LinkLocalLoopback
.
Bytes
(),
IP6Loopback
.
Bytes
(),
}
// IsIPLoopback returns whether a Multiaddr is a "Loopback" IP address
// This means either /ip4/127.*.*.*, /ip6/::1, or /ip6/fe80::1
func
IsIPLoopback
(
m
ma
.
Multiaddr
)
bool
{
b
:=
m
.
Bytes
()
for
_
,
prefix
:=
range
lo
cal
Prefixes
{
for
_
,
prefix
:=
range
lo
opback
Prefixes
{
if
bytes
.
HasPrefix
(
b
,
prefix
)
{
return
true
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment