mirror of https://github.com/gorilla/websocket.git
try https proxy
This commit is contained in:
parent
e8629af678
commit
d229c9f93d
12
proxy.go
12
proxy.go
|
@ -6,6 +6,7 @@ package websocket
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"net"
|
||||
|
@ -20,10 +21,21 @@ func (fn netDialerFunc) Dial(network, addr string) (net.Conn, error) {
|
|||
return fn(network, addr)
|
||||
}
|
||||
|
||||
type tlsDialer struct {
|
||||
}
|
||||
|
||||
func (t *tlsDialer) Dial(network, addr string) (c net.Conn, err error) {
|
||||
return tls.DialWithDialer(&net.Dialer{}, network, addr, &tls.Config{})
|
||||
}
|
||||
|
||||
func init() {
|
||||
proxy_RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
|
||||
return &httpProxyDialer{proxyURL: proxyURL, forwardDial: forwardDialer.Dial}, nil
|
||||
})
|
||||
proxy_RegisterDialerType("https", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
|
||||
dialer := &tlsDialer{}
|
||||
return &httpProxyDialer{proxyURL: proxyURL, forwardDial: dialer.Dial}, nil
|
||||
})
|
||||
}
|
||||
|
||||
type httpProxyDialer struct {
|
||||
|
|
Loading…
Reference in New Issue