]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Move ut_pex back into the "m" map
authorMatt Joiner <anacrolix@gmail.com>
Wed, 25 Mar 2015 04:49:27 +0000 (15:49 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 25 Mar 2015 04:49:27 +0000 (15:49 +1100)
client.go

index b355486dafc6a088fdadc988000095a89fe4f0a3..b6aad982b988c3ff9f8e9d72f764e5f1792ad27d 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1210,9 +1210,14 @@ func (me *Client) sendInitialMessages(conn *connection, torrent *torrent) {
                        ExtendedID: pp.HandshakeExtendedID,
                        ExtendedPayload: func() []byte {
                                d := map[string]interface{}{
-                                       "m": map[string]int{
-                                               "ut_metadata": metadataExtendedId,
-                                       },
+                                       "m": func() (ret map[string]int) {
+                                               ret = make(map[string]int, 2)
+                                               ret["ut_metadata"] = metadataExtendedId
+                                               if !me.config.DisablePEX {
+                                                       ret["ut_pex"] = pexExtendedId
+                                               }
+                                               return
+                                       }(),
                                        "v": extendedHandshakeClientVersion,
                                        // No upload queue is implemented yet.
                                        "reqq": func() int {
@@ -1225,9 +1230,6 @@ func (me *Client) sendInitialMessages(conn *connection, torrent *torrent) {
                                        }(),
                                        "e": 1, // Awwww yeah
                                }
-                               if !me.config.DisablePEX {
-                                       d["ut_pex"] = pexExtendedId
-                               }
                                if torrent.metadataSizeKnown() {
                                        d["metadata_size"] = torrent.metadataSize()
                                }