fix(proxy): add shared transport for proxies (#1808)

fix(proxy): use separate transport for proxies
This commit is contained in:
ze0s 2024-11-06 18:55:23 +01:00 committed by GitHub
parent 59c5858bf0
commit 41216babe6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View file

@ -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 != "" {

View file

@ -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,