mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
fix(proxy): add shared transport for proxies (#1808)
fix(proxy): use separate transport for proxies
This commit is contained in:
parent
59c5858bf0
commit
41216babe6
2 changed files with 21 additions and 1 deletions
|
@ -160,7 +160,7 @@ func GetProxiedHTTPClient(p *domain.Proxy) (*http.Client, error) {
|
|||
proxyUrl.User = url.UserPassword(p.User, p.Pass)
|
||||
}
|
||||
|
||||
transport := sharedhttp.TransportTLSInsecure
|
||||
transport := sharedhttp.ProxyTransport
|
||||
|
||||
// set user and pass if not empty
|
||||
if p.User != "" && p.Pass != "" {
|
||||
|
|
|
@ -52,6 +52,26 @@ var TransportTLSInsecure = &http.Transport{
|
|||
},
|
||||
}
|
||||
|
||||
var ProxyTransport = &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 30 * time.Second, // default transport value
|
||||
KeepAlive: 30 * time.Second, // default transport value
|
||||
}).DialContext,
|
||||
ForceAttemptHTTP2: true, // default is true; since HTTP/2 multiplexes a single TCP connection.
|
||||
MaxIdleConns: 100, // default transport value
|
||||
MaxIdleConnsPerHost: 10, // default is 2, so we want to increase the number to use establish more connections.
|
||||
IdleConnTimeout: 90 * time.Second, // default transport value
|
||||
ResponseHeaderTimeout: 120 * time.Second, // servers can respond slowly - this should fix some portion of releases getting stuck as pending.
|
||||
TLSHandshakeTimeout: 10 * time.Second, // default transport value
|
||||
ExpectContinueTimeout: 1 * time.Second, // default transport value
|
||||
ReadBufferSize: 65536,
|
||||
WriteBufferSize: 65536,
|
||||
TLSClientConfig: &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
},
|
||||
}
|
||||
|
||||
var Client = &http.Client{
|
||||
Timeout: 60 * time.Second,
|
||||
Transport: Transport,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue