MCPcopy
hub / github.com/jpillora/chisel / setProxy

Method setProxy

client/client.go:265–294  ·  view source on GitHub ↗
(u *url.URL, d *websocket.Dialer)

Source from the content-addressed store, hash-verified

263}
264
265func (c *Client) setProxy(u *url.URL, d *websocket.Dialer) error {
266 // CONNECT proxy
267 if !strings.HasPrefix(u.Scheme, "socks") {
268 d.Proxy = func(*http.Request) (*url.URL, error) {
269 return u, nil
270 }
271 return nil
272 }
273 // SOCKS5 proxy
274 if u.Scheme != "socks" && u.Scheme != "socks5h" {
275 return fmt.Errorf(
276 "unsupported socks proxy type: %s:// (only socks5h:// or socks:// is supported)",
277 u.Scheme,
278 )
279 }
280 var auth *proxy.Auth
281 if u.User != nil {
282 pass, _ := u.User.Password()
283 auth = &proxy.Auth{
284 User: u.User.Username(),
285 Password: pass,
286 }
287 }
288 socksDialer, err := proxy.SOCKS5("tcp", u.Host, auth, proxy.Direct)
289 if err != nil {
290 return err
291 }
292 d.NetDial = socksDialer.Dial
293 return nil
294}
295
296// Wait blocks while the client is running.
297func (c *Client) Wait() error {

Callers 1

connectionOnceMethod · 0.95

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected