Move back to net.IP for extended handshake message IPs

This commit is contained in:
Matt Joiner 2018-07-12 00:00:07 +10:00
parent a4a123b04e
commit ba8ec1a787
2 changed files with 8 additions and 6 deletions

View File

@ -839,11 +839,11 @@ func (cl *Client) sendInitialMessages(conn *connection, torrent *Torrent) {
Encryption: !cl.config.DisableEncryption,
Port: cl.incomingPeerPort(),
MetadataSize: torrent.metadataSize(),
}
// 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())
Ipv4: pp.CompactIp(cl.config.PublicIp4.To4()),
Ipv6: cl.config.PublicIp6.To16(),
}
if !cl.config.DisablePEX {
msg.M[pp.ExtensionNamePex] = pexExtendedId
}

View File

@ -1,5 +1,7 @@
package peer_protocol
import "net"
// http://www.bittorrent.org/beps/bep_0010.html
type (
ExtendedHandshakeMessage struct {
@ -13,8 +15,8 @@ type (
// 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