]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Move back to net.IP for extended handshake message IPs
authorMatt Joiner <anacrolix@gmail.com>
Wed, 11 Jul 2018 14:00:07 +0000 (00:00 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 11 Jul 2018 14:00:07 +0000 (00:00 +1000)
client.go
peer_protocol/extended.go

index 975106f40a1a505888f8480cfaa98cd129326fbc..e3182fad0a7487e26ec9d596c2b1125f23a91abd 100644 (file)
--- a/client.go
+++ b/client.go
@@ -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.
+                                       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
                                }
index a02a96f6b808f475cc6ce11084232fbc1956c4dc..ae5f124e2bc44124c8101b8630f245ccdb0bf7af 100644 (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