6 "github.com/anacrolix/dht/v2/krpc"
8 "github.com/anacrolix/torrent/peer_protocol"
11 // Peer connection info, handed about publicly.
17 // Peer is known to support encryption.
18 SupportsEncryption bool
19 peer_protocol.PexPeerFlags
20 // Whether we can ignore poor or bad behaviour from the peer.
24 // FromPex generate Peer from peer exchange
25 func (me *Peer) FromPex(na krpc.NodeAddr, fs peer_protocol.PexPeerFlags) {
26 me.IP = append([]byte(nil), na.IP...)
28 me.Source = peerSourcePex
29 // If they prefer encryption, they must support it.
30 if fs.Get(peer_protocol.PexPrefersEncryption) {
31 me.SupportsEncryption = true
36 func (me Peer) addr() IpPort {
37 return IpPort{IP: me.IP, Port: uint16(me.Port)}