From 927866e881c0563a77d31f6e401c6d1a8ab17c1e Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 9 Feb 2021 19:22:38 +1100 Subject: [PATCH] Limit conns per host across webseed clients --- torrent.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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), -- 2.44.0