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
6a0950fe
Commit
6a0950fe
authored
Dec 21, 2021
by
Marten Seemann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename AddrOverNonLocalIP to IsIpv6LinkLocal
parent
67926707
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
net/ip.go
net/ip.go
+2
-2
net/resolve.go
net/resolve.go
+1
-1
net/resolve_test.go
net/resolve_test.go
+2
-2
No files found.
net/ip.go
View file @
6a0950fe
...
...
@@ -95,8 +95,8 @@ func IsIPUnspecified(m ma.Multiaddr) bool {
return
net
.
IP
(
c
.
RawValue
())
.
IsUnspecified
()
}
//
AddrOverNon
Local
IP
returns whether the addr uses a non-local ip link
func
AddrOverNon
Local
IP
(
a
ma
.
Multiaddr
)
bool
{
//
IsIpv6Link
Local returns whether the addr uses a non-local ip link
func
IsIpv6Link
Local
(
a
ma
.
Multiaddr
)
bool
{
split
:=
ma
.
Split
(
a
)
if
len
(
split
)
<
1
{
return
false
...
...
net/resolve.go
View file @
6a0950fe
...
...
@@ -74,7 +74,7 @@ func interfaceAddresses() ([]ma.Multiaddr, error) {
var
out
[]
ma
.
Multiaddr
for
_
,
a
:=
range
maddrs
{
if
!
AddrOverNon
Local
IP
(
a
)
{
if
!
IsIpv6Link
Local
(
a
)
{
continue
}
out
=
append
(
out
,
a
)
...
...
net/resolve_test.go
View file @
6a0950fe
...
...
@@ -67,9 +67,9 @@ func TestAddrOverNonLocalIP(t *testing.T) {
newMultiaddr
(
t
,
"/ip4/1.2.3.4/udp/1234/utp"
),
}
for
_
,
addr
:=
range
bad
{
require
.
Falsef
(
t
,
AddrOverNon
Local
IP
(
addr
),
"%s is a link local addr"
,
addr
)
require
.
Falsef
(
t
,
IsIpv6Link
Local
(
addr
),
"%s is a link local addr"
,
addr
)
}
for
_
,
addr
:=
range
good
{
require
.
Truef
(
t
,
AddrOverNon
Local
IP
(
addr
),
"%s is not a link local addr"
,
addr
)
require
.
Truef
(
t
,
IsIpv6Link
Local
(
addr
),
"%s is not a link local addr"
,
addr
)
}
}
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