client.go | 8 ++++---- peer_protocol/extended.go | 6 ++++-- diff --git a/client.go b/client.go index 975106f40a1a505888f8480cfaa98cd129326fbc..e3182fad0a7487e26ec9d596c2b1125f23a91abd 100644 --- a/client.go +++ b/client.go @@ -839,11 +839,11 @@ YourIp: pp.CompactIp(missinggo.AddrIP(conn.remoteAddr())), Encryption: !cl.config.DisableEncryption, Port: cl.incomingPeerPort(), MetadataSize: torrent.metadataSize(), + // TODO: We can figured these out specific to the socket + // used. + Ipv4: pp.CompactIp(cl.config.PublicIp4.To4()), + Ipv6: cl.config.PublicIp6.To16(), } - // TODO: We can figured these out specific to the socket - // used. - copy(msg.Ipv4[:], cl.config.PublicIp4.To4()) - copy(msg.Ipv6[:], cl.config.PublicIp6.To16()) if !cl.config.DisablePEX { msg.M[pp.ExtensionNamePex] = pexExtendedId } diff --git a/peer_protocol/extended.go b/peer_protocol/extended.go index a02a96f6b808f475cc6ce11084232fbc1956c4dc..ae5f124e2bc44124c8101b8630f245ccdb0bf7af 100644 --- a/peer_protocol/extended.go +++ b/peer_protocol/extended.go @@ -1,5 +1,7 @@ package peer_protocol +import "net" + // http://www.bittorrent.org/beps/bep_0010.html type ( ExtendedHandshakeMessage struct { @@ -13,8 +15,8 @@ // The local client port. It would be redundant for the receiving side of // a connection to send this. Port int `bencode:"p,omitempty"` YourIp CompactIp `bencode:"yourip,omitempty"` - Ipv4 [4]byte `bencode:"ipv4,omitempty"` - Ipv6 [16]byte `bencode:"ipv6,omitempty"` + Ipv4 CompactIp `bencode:"ipv4,omitempty"` + Ipv6 net.IP `bencode:"ipv6,omitempty"` } ExtensionName string