mirror of https://github.com/gorilla/websocket.git
Compare commits
6 Commits
883b0a2814
...
f74fc8665d
Author | SHA1 | Date |
---|---|---|
Sleeyax | f74fc8665d | |
Corey Daley | ea5afd45e1 | |
Corey Daley | fe5bdd86f3 | |
Sleeyax | 36867e9319 | |
Sleeyax | adb13885c2 | |
Sleeyax | 502bd65db8 |
16
client.go
16
client.go
|
@ -66,6 +66,12 @@ type Dialer struct {
|
||||||
// TLSClientConfig is ignored.
|
// TLSClientConfig is ignored.
|
||||||
NetDialTLSContext func(ctx context.Context, network, addr string) (net.Conn, error)
|
NetDialTLSContext func(ctx context.Context, network, addr string) (net.Conn, error)
|
||||||
|
|
||||||
|
// ProxyTLSConnection specifies the dial function for creating TLS connections through a Proxy. If
|
||||||
|
// ProxyTLSConnection is nil, NetDialTLSContext is used.
|
||||||
|
// If ProxyTLSConnection is set, Dial assumes the TLS handshake is done there and
|
||||||
|
// TLSClientConfig is ignored.
|
||||||
|
ProxyTLSConnection func(ctx context.Context, hostPort string, proxyConn net.Conn) (net.Conn, error)
|
||||||
|
|
||||||
// Proxy specifies a function to return a proxy for a given
|
// Proxy specifies a function to return a proxy for a given
|
||||||
// Request. If the function returns a non-nil error, the
|
// Request. If the function returns a non-nil error, the
|
||||||
// request is aborted with the provided error.
|
// request is aborted with the provided error.
|
||||||
|
@ -334,7 +340,14 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if u.Scheme == "https" && d.NetDialTLSContext == nil {
|
if u.Scheme == "https" {
|
||||||
|
if d.ProxyTLSConnection != nil && d.Proxy != nil {
|
||||||
|
// If we are connected to a proxy, perform the TLS handshake through the existing tunnel
|
||||||
|
netConn, err = d.ProxyTLSConnection(ctx, hostPort, netConn)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
} else if d.NetDialTLSContext == nil {
|
||||||
// If NetDialTLSContext is set, assume that the TLS handshake has already been done
|
// If NetDialTLSContext is set, assume that the TLS handshake has already been done
|
||||||
|
|
||||||
cfg := cloneTLSConfig(d.TLSClientConfig)
|
cfg := cloneTLSConfig(d.TLSClientConfig)
|
||||||
|
@ -356,6 +369,7 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize, d.WriteBufferPool, nil, nil)
|
conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize, d.WriteBufferPool, nil, nil)
|
||||||
|
|
||||||
|
|
2
proxy.go
2
proxy.go
|
@ -33,7 +33,7 @@ type httpProxyDialer struct {
|
||||||
|
|
||||||
func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error) {
|
func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error) {
|
||||||
hostPort, _ := hostPortNoPort(hpd.proxyURL)
|
hostPort, _ := hostPortNoPort(hpd.proxyURL)
|
||||||
conn, err := hpd.forwardDial(network, hostPort)
|
conn, err := net.Dial(network, hostPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue