mirror of https://github.com/gorilla/websocket.git
do not edit the generated x_net_proxy.go
This commit is contained in:
parent
7f3a5bcae0
commit
f724bd6a6c
11
proxy.go
11
proxy.go
|
@ -15,6 +15,13 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// // proxyDialerEx extends the generated proxy_Dialer
|
||||
type proxyDialerEx interface {
|
||||
proxy_Dialer
|
||||
// UsesTLS indicates whether we expect to dial to a TLS proxy
|
||||
UsesTLS() bool
|
||||
}
|
||||
|
||||
type netDialerFunc struct {
|
||||
fn func(network, addr string) (net.Conn, error)
|
||||
usesTLS bool
|
||||
|
@ -30,11 +37,11 @@ func (ndf *netDialerFunc) UsesTLS() bool {
|
|||
|
||||
func init() {
|
||||
proxy_RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
|
||||
return &httpProxyDialer{proxyURL: proxyURL, forwardDial: forwardDialer.Dial, usesTLS: forwardDialer.UsesTLS()}, nil
|
||||
return &httpProxyDialer{proxyURL: proxyURL, forwardDial: forwardDialer.Dial, usesTLS: false}, nil
|
||||
})
|
||||
proxy_RegisterDialerType("https", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
|
||||
fwd := forwardDialer.Dial
|
||||
if !forwardDialer.UsesTLS() {
|
||||
if dialerEx, ok := forwardDialer.(proxyDialerEx); !ok || !dialerEx.UsesTLS() {
|
||||
tlsDialer := &tls.Dialer{
|
||||
Config: &tls.Config{},
|
||||
NetDialer: &net.Dialer{},
|
||||
|
|
|
@ -27,10 +27,6 @@ func (proxy_direct) Dial(network, addr string) (net.Conn, error) {
|
|||
return net.Dial(network, addr)
|
||||
}
|
||||
|
||||
func (proxy_direct) UsesTLS() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// A PerHost directs connections to a default Dialer unless the host name
|
||||
// requested matches one of a number of exceptions.
|
||||
type proxy_PerHost struct {
|
||||
|
@ -63,10 +59,6 @@ func (p *proxy_PerHost) Dial(network, addr string) (c net.Conn, err error) {
|
|||
return p.dialerForRequest(host).Dial(network, addr)
|
||||
}
|
||||
|
||||
func (p *proxy_PerHost) UsesTLS() bool {
|
||||
return p.def.UsesTLS() || p.bypass.UsesTLS()
|
||||
}
|
||||
|
||||
func (p *proxy_PerHost) dialerForRequest(host string) proxy_Dialer {
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
for _, net := range p.bypassNetworks {
|
||||
|
@ -169,8 +161,6 @@ func (p *proxy_PerHost) AddHost(host string) {
|
|||
type proxy_Dialer interface {
|
||||
// Dial connects to the given address via the proxy.
|
||||
Dial(network, addr string) (c net.Conn, err error)
|
||||
// UsesTLS indicates whether we expect to dial to a TLS proxy
|
||||
UsesTLS() bool
|
||||
}
|
||||
|
||||
// Auth contains authentication parameters that specific Dialers may require.
|
||||
|
@ -348,10 +338,6 @@ func (s *proxy_socks5) Dial(network, addr string) (net.Conn, error) {
|
|||
return conn, nil
|
||||
}
|
||||
|
||||
func (s *proxy_socks5) UsesTLS() bool {
|
||||
return s.forward.UsesTLS()
|
||||
}
|
||||
|
||||
// connect takes an existing connection to a socks5 proxy server,
|
||||
// and commands the server to extend that connection to target,
|
||||
// which must be a canonical address with a host and port.
|
||||
|
|
Loading…
Reference in New Issue