]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Limit conns per host across webseed clients v1.25.0
authorMatt Joiner <anacrolix@gmail.com>
Tue, 9 Feb 2021 08:22:38 +0000 (19:22 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 9 Feb 2021 08:22:38 +0000 (19:22 +1100)
torrent.go

index 26f49b82a6b289a08e9526d015b5d974db90f902..a4ae4b48c4bb340a310edefa1a67a304038e34e6 100644 (file)
@@ -2103,6 +2103,12 @@ func (t *Torrent) callbacks() *Callbacks {
        return &t.cl.config.Callbacks
 }
 
+var WebseedHttpClient = &http.Client{
+       Transport: &http.Transport{
+               MaxConnsPerHost: 10,
+       },
+}
+
 func (t *Torrent) addWebSeed(url string) {
        if t.cl.config.DisableWebseeds {
                return
@@ -2125,7 +2131,7 @@ func (t *Torrent) addWebSeed(url string) {
                },
                client: webseed.Client{
                        // Consider a MaxConnsPerHost in the transport for this, possibly in a global Client.
-                       HttpClient: http.DefaultClient,
+                       HttpClient: WebseedHttpClient,
                        Url:        url,
                },
                activeRequests: make(map[Request]webseed.Request, maxRequests),