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
p2p
go-p2p-kad-dht
Commits
ee31a149
Unverified
Commit
ee31a149
authored
Apr 08, 2021
by
Marten Seemann
Committed by
GitHub
Apr 08, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #710 from libp2p/fix-staticcheck
various staticcheck fixes
parents
f05ebb20
5d95bf1e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
dht_filters.go
dht_filters.go
+1
-0
dht_filters_test.go
dht_filters_test.go
+3
-4
routing.go
routing.go
+2
-2
No files found.
dht_filters.go
View file @
ee31a149
...
@@ -197,6 +197,7 @@ func isEUI(ip net.IP) bool {
...
@@ -197,6 +197,7 @@ func isEUI(ip net.IP) bool {
}
}
func
sameV6Net
(
a
,
b
net
.
IP
)
bool
{
func
sameV6Net
(
a
,
b
net
.
IP
)
bool
{
//lint:ignore SA1021 We're comparing only parts of the IP address here.
return
len
(
a
)
==
net
.
IPv6len
&&
len
(
b
)
==
net
.
IPv6len
&&
bytes
.
Equal
(
a
[
0
:
8
],
b
[
0
:
8
])
//nolint
return
len
(
a
)
==
net
.
IPv6len
&&
len
(
b
)
==
net
.
IPv6len
&&
bytes
.
Equal
(
a
[
0
:
8
],
b
[
0
:
8
])
//nolint
}
}
...
...
dht_filters_test.go
View file @
ee31a149
...
@@ -8,21 +8,20 @@ import (
...
@@ -8,21 +8,20 @@ import (
ic
"github.com/libp2p/go-libp2p-core/crypto"
ic
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/multiformats/go-multiaddr"
ma
"github.com/multiformats/go-multiaddr"
ma
"github.com/multiformats/go-multiaddr"
manet
"github.com/multiformats/go-multiaddr/net"
manet
"github.com/multiformats/go-multiaddr/net"
)
)
func
TestIsRelay
(
t
*
testing
.
T
)
{
func
TestIsRelay
(
t
*
testing
.
T
)
{
a
,
_
:=
m
ultiaddr
.
NewMultiaddr
(
"/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt"
)
a
,
_
:=
m
a
.
NewMultiaddr
(
"/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt"
)
if
!
isRelayAddr
(
a
)
{
if
!
isRelayAddr
(
a
)
{
t
.
Fatalf
(
"thought %s was not a relay"
,
a
)
t
.
Fatalf
(
"thought %s was not a relay"
,
a
)
}
}
a
,
_
=
m
ultiaddr
.
NewMultiaddr
(
"/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt"
)
a
,
_
=
m
a
.
NewMultiaddr
(
"/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt"
)
if
!
isRelayAddr
(
a
)
{
if
!
isRelayAddr
(
a
)
{
t
.
Fatalf
(
"thought %s was not a relay"
,
a
)
t
.
Fatalf
(
"thought %s was not a relay"
,
a
)
}
}
a
,
_
=
m
ultiaddr
.
NewMultiaddr
(
"/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ"
)
a
,
_
=
m
a
.
NewMultiaddr
(
"/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ"
)
if
isRelayAddr
(
a
)
{
if
isRelayAddr
(
a
)
{
t
.
Fatalf
(
"thought %s was a relay"
,
a
)
t
.
Fatalf
(
"thought %s was a relay"
,
a
)
}
}
...
...
routing.go
View file @
ee31a149
...
@@ -327,10 +327,10 @@ func (dht *IpfsDHT) getValues(ctx context.Context, key string, stopQuery chan st
...
@@ -327,10 +327,10 @@ func (dht *IpfsDHT) getValues(ctx context.Context, key string, stopQuery chan st
ID
:
p
,
ID
:
p
,
})
})
return
nil
,
err
return
nil
,
err
default
:
return
nil
,
err
case
nil
,
internal
.
ErrInvalidRecord
:
case
nil
,
internal
.
ErrInvalidRecord
:
// in either of these cases, we want to keep going
// in either of these cases, we want to keep going
default
:
return
nil
,
err
}
}
// TODO: What should happen if the record is invalid?
// TODO: What should happen if the record is invalid?
...
...
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