]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add ClientConfig.AlwaysWantConns
authorMatt Joiner <anacrolix@gmail.com>
Tue, 21 Sep 2021 03:04:51 +0000 (13:04 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 21 Sep 2021 03:04:51 +0000 (13:04 +1000)
client.go
config.go

index e7683016b2ae2e14d110b43d5626f6730ee21e64..ae40f458e1ff6d24b356e754afba00f380b45ffe 100644 (file)
--- a/client.go
+++ b/client.go
@@ -451,6 +451,9 @@ func (cl *Client) ipIsBlocked(ip net.IP) bool {
 }
 
 func (cl *Client) wantConns() bool {
+       if cl.config.AlwaysWantConns {
+               return true
+       }
        for _, t := range cl.torrents {
                if t.wantConns() {
                        return true
index 1895f3c37aa715a5d050c481fb08d29691351b87..0e3cd2c2a24a1a4083c9ed9861db1565d20cf8ad 100644 (file)
--- a/config.go
+++ b/config.go
@@ -139,6 +139,9 @@ type ClientConfig struct {
        DropMutuallyCompletePeers bool
        // Whether to accept peer connections at all.
        AcceptPeerConnections bool
+       // Whether a Client should want conns without delegating to any attached Torrents. This is
+       // useful when torrents might be added dynmically in callbacks for example.
+       AlwaysWantConns bool
 
        // OnQuery hook func
        DHTOnQuery func(query *krpc.Msg, source net.Addr) (propagate bool)