MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / NewUtlsHTTPClient

Function NewUtlsHTTPClient

internal/runtime/executor/helps/utls_client.go:158–193  ·  view source on GitHub ↗

NewUtlsHTTPClient creates an HTTP client using utls Chrome TLS fingerprint. Use this for provider requests that need a Chrome-like TLS fingerprint. Falls back to standard transport for non-HTTPS requests.

(ctx context.Context, cfg *config.Config, auth *cliproxyauth.Auth, timeout time.Duration)

Source from the content-addressed store, hash-verified

156// Use this for provider requests that need a Chrome-like TLS fingerprint.
157// Falls back to standard transport for non-HTTPS requests.
158func NewUtlsHTTPClient(ctx context.Context, cfg *config.Config, auth *cliproxyauth.Auth, timeout time.Duration) *http.Client {
159 var proxyURL string
160 if auth != nil {
161 proxyURL = strings.TrimSpace(auth.ProxyURL)
162 }
163 if proxyURL == "" && cfg != nil {
164 proxyURL = strings.TrimSpace(cfg.ProxyURL)
165 }
166
167 var ctxRoundTripper http.RoundTripper
168 if ctx != nil {
169 ctxRoundTripper, _ = ctx.Value("cliproxy.roundtripper").(http.RoundTripper)
170 }
171
172 var utlsRT http.RoundTripper = newUtlsRoundTripper(proxyURL)
173 var standardTransport http.RoundTripper = http.DefaultTransport
174 if proxyURL != "" {
175 if transport := buildProxyTransport(proxyURL); transport != nil {
176 standardTransport = transport
177 }
178 } else if ctxRoundTripper != nil {
179 utlsRT = ctxRoundTripper
180 standardTransport = ctxRoundTripper
181 }
182
183 client := &http.Client{
184 Transport: &fallbackRoundTripper{
185 utls: utlsRT,
186 fallback: standardTransport,
187 },
188 }
189 if timeout > 0 {
190 client.Timeout = timeout
191 }
192 return client
193}

Callers 9

HttpRequestMethod · 0.92
ExecuteMethod · 0.92
executeCompactMethod · 0.92
ExecuteStreamMethod · 0.92
HttpRequestMethod · 0.92
ExecuteMethod · 0.92
ExecuteStreamMethod · 0.92
CountTokensMethod · 0.92

Calls 2

newUtlsRoundTripperFunction · 0.70
buildProxyTransportFunction · 0.70