]> Sergey Matveev's repositories - btrtrc.git/commitdiff
added support for half-open peers in KnownSwarm() function
authorBora M. Alper <bora@boramalper.org>
Sat, 16 Sep 2017 10:48:16 +0000 (11:48 +0100)
committerBora M. Alper <bora@boramalper.org>
Sat, 16 Sep 2017 10:48:16 +0000 (11:48 +0100)
torrent.go

index aba33139a9154348f10d8e8ca91fc49bb0f133c8..d476e170b8d5c107f622cccc4d7d5a88079189da 100644 (file)
@@ -131,6 +131,11 @@ func (t *Torrent) KnownSwarm() (ks []Peer) {
                ks = append(ks, peer)
        }
 
+       // Add half-open peers to the list
+       for _, peer := range t.halfOpen {
+               ks = append(ks, peer)
+       }
+
        // Add active peers to the list
        for conn := range t.conns {
                host, portString, err := net.SplitHostPort(conn.remoteAddr().String())
@@ -149,15 +154,16 @@ func (t *Torrent) KnownSwarm() (ks []Peer) {
                        IP: ip,
                        Port: port,
                        Source: conn.Discovery,
-                       // TODO: the connection can be unencrypted due to our (or the peer's) preference,
-                       //       but the remote peer might support the encryption. Find a better way to query
-                       //       that information, if possible.
+                       // > If the connection is encrypted, that's certainly enough to set SupportsEncryption.
+                       // > But if we're not connected to them with an encrypted connection, I couldn't say
+                       // > what's appropriate. We can carry forward the SupportsEncryption value as we
+                       // > received it from trackers/DHT/PEX, or just use the encryption state for the
+                       // > connection. It's probably easiest to do the latter for now.
+                       // https://github.com/anacrolix/torrent/pull/188
                        SupportsEncryption: conn.encrypted,
                })
        }
 
-       // TODO: how can we add half-open peers?
-
        return
 }