Dial connects to the address addr on the given network via the SOCKS5 proxy.
(network, addr string)
| 321 | |
| 322 | // Dial connects to the address addr on the given network via the SOCKS5 proxy. |
| 323 | func (s *proxy_socks5) Dial(network, addr string) (net.Conn, error) { |
| 324 | switch network { |
| 325 | case "tcp", "tcp6", "tcp4": |
| 326 | default: |
| 327 | return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network) |
| 328 | } |
| 329 | |
| 330 | conn, err := s.forward.Dial(s.network, s.addr) |
| 331 | if err != nil { |
| 332 | return nil, err |
| 333 | } |
| 334 | if err := s.connect(conn, addr); err != nil { |
| 335 | conn.Close() |
| 336 | return nil, err |
| 337 | } |
| 338 | return conn, nil |
| 339 | } |
| 340 | |
| 341 | // connect takes an existing connection to a socks5 proxy server, |
| 342 | // and commands the server to extend that connection to target, |