]> Sergey Matveev's repositories - btrtrc.git/blobdiff - peer_info.go
Drop support for go 1.20
[btrtrc.git] / peer_info.go
index 049ae15276cf8c0050536f4e9f6fcfec9d4a3651..e7b1b7c8053c1297403e4818e9c4b7b592f26789 100644 (file)
@@ -1,8 +1,6 @@
 package torrent
 
 import (
-       "net"
-
        "github.com/anacrolix/dht/v2/krpc"
 
        "github.com/anacrolix/torrent/peer_protocol"
@@ -11,7 +9,7 @@ import (
 // Peer connection info, handed about publicly.
 type PeerInfo struct {
        Id     [20]byte
-       Addr   net.Addr
+       Addr   PeerRemoteAddr
        Source PeerSource
        // Peer is known to support encryption.
        SupportsEncryption bool
@@ -20,7 +18,7 @@ type PeerInfo struct {
        Trusted bool
 }
 
-func (me PeerInfo) Equal(other PeerInfo) bool {
+func (me PeerInfo) equal(other PeerInfo) bool {
        return me.Id == other.Id &&
                me.Addr.String() == other.Addr.String() &&
                me.Source == other.Source &&
@@ -41,5 +39,6 @@ func (me *PeerInfo) FromPex(na krpc.NodeAddr, fs peer_protocol.PexPeerFlags) {
 }
 
 func (me PeerInfo) addr() IpPort {
-       return IpPort{IP: addrIpOrNil(me.Addr), Port: uint16(addrPortOrZero(me.Addr))}
+       ipPort, _ := tryIpPortFromNetAddr(me.Addr)
+       return IpPort{ipPort.IP, uint16(ipPort.Port)}
 }