Unverified Commit ee31a149 authored by Marten Seemann's avatar Marten Seemann Committed by GitHub

Merge pull request #710 from libp2p/fix-staticcheck

various staticcheck fixes
parents f05ebb20 5d95bf1e
...@@ -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
} }
......
...@@ -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, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt") a, _ := ma.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, _ = multiaddr.NewMultiaddr("/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt") a, _ = ma.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, _ = multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ") a, _ = ma.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)
} }
......
...@@ -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?
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment