]> Sergey Matveev's repositories - btrtrc.git/blobdiff - torrent.go
Limit conns per host across webseed clients
[btrtrc.git] / 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),