@@ -14,21 +14,32 @@ import (
14
14
"strings"
15
15
)
16
16
17
- type netDialerFunc func (network , addr string ) (net.Conn , error )
17
+ // type netDialerFunc func(network, addr string) (net.Conn, error)
18
+ //
19
+ // func (fn netDialerFunc) Dial(network, addr string) (net.Conn, error) {
20
+ // return fn(network, addr)
21
+ // }
22
+ type netDialer struct {
23
+ proxyHeader http.Header
24
+ f func (network , addr string ) (net.Conn , error )
25
+ }
18
26
19
- func (fn netDialerFunc ) Dial (network , addr string ) (net.Conn , error ) {
20
- return fn (network , addr )
27
+ func (n netDialer ) Dial (network , addr string ) (net.Conn , error ) {
28
+ return n . f (network , addr )
21
29
}
22
30
23
31
func init () {
24
32
proxy_RegisterDialerType ("http" , func (proxyURL * url.URL , forwardDialer proxy_Dialer ) (proxy_Dialer , error ) {
25
- return & httpProxyDialer {proxyURL : proxyURL , forwardDial : forwardDialer .Dial }, nil
33
+ p , _ := forwardDialer .(* netDialer )
34
+ return & httpProxyDialer {proxyURL : proxyURL , forwardDial : forwardDialer .Dial , proxyHeader : p .proxyHeader }, nil
35
+ // return &httpProxyDialer{proxyURL: proxyURL, forwardDial: forwardDialer.Dial}, nil
26
36
})
27
37
}
28
38
29
39
type httpProxyDialer struct {
30
40
proxyURL * url.URL
31
41
forwardDial func (network , addr string ) (net.Conn , error )
42
+ proxyHeader http.Header
32
43
}
33
44
34
45
func (hpd * httpProxyDialer ) Dial (network string , addr string ) (net.Conn , error ) {
@@ -47,6 +58,10 @@ func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error)
47
58
}
48
59
}
49
60
61
+ for k , v := range hpd .proxyHeader {
62
+ connectHeader [k ] = v
63
+ }
64
+
50
65
connectReq := & http.Request {
51
66
Method : "CONNECT" ,
52
67
URL : & url.URL {Opaque : addr },
0 commit comments