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

Function BuildDialer

sdk/proxyutil/proxy.go:128–151  ·  view source on GitHub ↗

BuildDialer constructs a proxy dialer for settings that operate at the connection layer.

(raw string)

Source from the content-addressed store, hash-verified

126
127// BuildDialer constructs a proxy dialer for settings that operate at the connection layer.
128func BuildDialer(raw string) (proxy.Dialer, Mode, error) {
129 setting, errParse := Parse(raw)
130 if errParse != nil {
131 return nil, setting.Mode, errParse
132 }
133
134 switch setting.Mode {
135 case ModeInherit:
136 return nil, setting.Mode, nil
137 case ModeDirect:
138 return proxy.Direct, setting.Mode, nil
139 case ModeProxy:
140 if setting.URL.Scheme == "http" || setting.URL.Scheme == "https" {
141 return &httpConnectDialer{proxyURL: setting.URL, dialer: proxy.Direct}, setting.Mode, nil
142 }
143 dialer, errDialer := proxy.FromURL(setting.URL, proxy.Direct)
144 if errDialer != nil {
145 return nil, setting.Mode, fmt.Errorf("create proxy dialer failed: %w", errDialer)
146 }
147 return dialer, setting.Mode, nil
148 default:
149 return nil, setting.Mode, nil
150 }
151}
152
153type httpConnectDialer struct {
154 proxyURL *url.URL

Callers 3

newUtlsRoundTripperFunction · 0.92
newUtlsRoundTripperFunction · 0.92

Calls 1

ParseFunction · 0.85

Tested by 1