From: Matt Joiner Date: Tue, 9 Feb 2021 08:22:38 +0000 (+1100) Subject: Limit conns per host across webseed clients X-Git-Tag: v1.25.0 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=927866e881c0563a77d31f6e401c6d1a8ab17c1e;p=btrtrc.git Limit conns per host across webseed clients --- diff --git a/torrent.go b/torrent.go index 26f49b82..a4ae4b48 100644 --- a/torrent.go +++ b/torrent.go @@ -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),