fixes various vet errors
This commit is contained in:
parent
98bd488466
commit
ad73cf8611
3
Peer.go
3
Peer.go
|
@ -21,6 +21,7 @@ type Peer struct {
|
|||
Trusted bool
|
||||
}
|
||||
|
||||
// FromPex generate Peer from peer exchange
|
||||
func (me *Peer) FromPex(na krpc.NodeAddr, fs peer_protocol.PexPeerFlags) {
|
||||
me.IP = append([]byte(nil), na.IP...)
|
||||
me.Port = na.Port
|
||||
|
@ -33,5 +34,5 @@ func (me *Peer) FromPex(na krpc.NodeAddr, fs peer_protocol.PexPeerFlags) {
|
|||
}
|
||||
|
||||
func (me Peer) addr() IpPort {
|
||||
return IpPort{me.IP, uint16(me.Port)}
|
||||
return IpPort{IP: me.IP, Port: uint16(me.Port)}
|
||||
}
|
||||
|
|
|
@ -9,21 +9,21 @@ import (
|
|||
|
||||
func TestBep40Priority(t *testing.T) {
|
||||
assert.EqualValues(t, peerPriority(0xec2d7224), bep40PriorityIgnoreError(
|
||||
IpPort{net.ParseIP("123.213.32.10"), 0},
|
||||
IpPort{net.ParseIP("98.76.54.32"), 0},
|
||||
IpPort{IP: net.ParseIP("123.213.32.10"), Port: 0},
|
||||
IpPort{IP: net.ParseIP("98.76.54.32"), Port: 0},
|
||||
))
|
||||
assert.EqualValues(t, peerPriority(0xec2d7224), bep40PriorityIgnoreError(
|
||||
IpPort{net.ParseIP("98.76.54.32"), 0},
|
||||
IpPort{net.ParseIP("123.213.32.10"), 0},
|
||||
IpPort{IP: net.ParseIP("98.76.54.32"), Port: 0},
|
||||
IpPort{IP: net.ParseIP("123.213.32.10"), Port: 0},
|
||||
))
|
||||
assert.Equal(t, peerPriority(0x99568189), bep40PriorityIgnoreError(
|
||||
IpPort{net.ParseIP("123.213.32.10"), 0},
|
||||
IpPort{net.ParseIP("123.213.32.234"), 0},
|
||||
IpPort{IP: net.ParseIP("123.213.32.10"), Port: 0},
|
||||
IpPort{IP: net.ParseIP("123.213.32.234"), Port: 0},
|
||||
))
|
||||
assert.EqualValues(t, "\x00\x00\x00\x00", func() []byte {
|
||||
b, _ := bep40PriorityBytes(
|
||||
IpPort{net.ParseIP("123.213.32.234"), 0},
|
||||
IpPort{net.ParseIP("123.213.32.234"), 0},
|
||||
IpPort{IP: net.ParseIP("123.213.32.234"), Port: 0},
|
||||
IpPort{IP: net.ParseIP("123.213.32.234"), Port: 0},
|
||||
)
|
||||
return b
|
||||
}())
|
||||
|
|
13
client.go
13
client.go
|
@ -1298,12 +1298,12 @@ func (cl *Client) publicIp(peer net.IP) net.IP {
|
|||
cl.config.PublicIp4,
|
||||
cl.findListenerIp(func(ip net.IP) bool { return ip.To4() != nil }),
|
||||
)
|
||||
} else {
|
||||
return firstNotNil(
|
||||
cl.config.PublicIp6,
|
||||
cl.findListenerIp(func(ip net.IP) bool { return ip.To4() == nil }),
|
||||
)
|
||||
}
|
||||
|
||||
return firstNotNil(
|
||||
cl.config.PublicIp6,
|
||||
cl.findListenerIp(func(ip net.IP) bool { return ip.To4() == nil }),
|
||||
)
|
||||
}
|
||||
|
||||
func (cl *Client) findListenerIp(f func(net.IP) bool) net.IP {
|
||||
|
@ -1314,9 +1314,10 @@ func (cl *Client) findListenerIp(f func(net.IP) bool) net.IP {
|
|||
|
||||
// Our IP as a peer should see it.
|
||||
func (cl *Client) publicAddr(peer net.IP) IpPort {
|
||||
return IpPort{cl.publicIp(peer), uint16(cl.incomingPeerPort())}
|
||||
return IpPort{IP: cl.publicIp(peer), Port: uint16(cl.incomingPeerPort())}
|
||||
}
|
||||
|
||||
// ListenAddrs addresses currently being listened to.
|
||||
func (cl *Client) ListenAddrs() (ret []net.Addr) {
|
||||
cl.lock()
|
||||
defer cl.unlock()
|
||||
|
|
|
@ -96,7 +96,7 @@ func BenchmarkConnectionMainReadLoop(b *testing.B) {
|
|||
ts := &torrentStorage{}
|
||||
t := &Torrent{
|
||||
cl: cl,
|
||||
storage: &storage.Torrent{ts},
|
||||
storage: &storage.Torrent{TorrentImpl: ts},
|
||||
pieceStateChanges: pubsub.NewPubSub(),
|
||||
}
|
||||
require.NoError(b, t.setInfo(&metainfo.Info{
|
||||
|
|
Loading…
Reference in New Issue