-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmr_worldwide.go
55 lines (49 loc) · 1.42 KB
/
mr_worldwide.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package prox5
import (
"crypto/tls"
"net/http"
"sync"
"time"
)
func (p5 *ProxyEngine) newHTTPClient() any {
timeout := p5.GetServerTimeout()
hc := &http.Client{
Transport: &http.Transport{
DialContext: p5.DialContext,
TLSClientConfig: &tls.Config{InsecureSkipVerify: p5.GetHTTPTLSVerificationStatus() == false}, //nolint:gosec
// TLSHandshakeTimeout: p5.GetServerTimeout(),
DisableKeepAlives: true,
DisableCompression: false,
// MaxIdleConnsPerHost: 5,
// MaxConnsPerHost: 0,
// IdleConnTimeout: 0,
// ResponseHeaderTimeout: 0,
// ExpectContinueTimeout: 0,
// TLSNextProto: nil,
// ProxyConnectHeader: nil,
// GetProxyConnectHeader: nil,
// MaxResponseHeaderBytes: 0,
// WriteBufferSize: 0,
// ReadBufferSize: 0,
// ForceAttemptHTTP2: false,
},
}
if timeout != time.Duration(0) {
hc.Timeout = timeout
}
return hc
}
// GetHTTPClient retrieves a pointer to an http.Client powered by mysteryDialer.
func (p5 *ProxyEngine) GetHTTPClient() *http.Client {
if p5.httpOptsDirty.Load() {
p5.httpClients = &sync.Pool{
New: p5.newHTTPClient,
}
p5.httpOptsDirty.Store(false)
}
return p5.httpClients.Get().(*http.Client)
}
// RoundTrip is Mr. WorldWide. Obviously. See: https://pkg.go.dev/net/http#RoundTripper
func (p5 *ProxyEngine) RoundTrip(req *http.Request) (*http.Response, error) {
return p5.GetHTTPClient().Do(req)
}