Skip to content

Commit 3d5c263

Browse files
committed
Add Dialer comment explaining interaction of net dial functions with proxy
1 parent 865c975 commit 3d5c263

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

client.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,37 @@ func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufS
5151
//
5252
// It is safe to call Dialer's methods concurrently.
5353
type Dialer struct {
54+
// Custom dial functions can be set on the Dialer to create the TCP connection
55+
// to the backend server. Multiple dial functions can be set simultaneously,
56+
// with the priority of the dial function as follows:
57+
// 1) NetDialTLSContext (only if backend server scheme is HTTPS)
58+
// 2) NetDialContext
59+
// 3) NetDial
60+
// IMPORTANT CAVEAT: If the "proxy" function field is also set, and it returns
61+
// a valid proxy URL, then the custom dial functions INSTEAD create the TCP
62+
// connection to the proxy. The matrix of proxy/backend schemes with custom dial
63+
// functions looks like:
64+
// 1) Proxy: HTTP, Backend: HTTP
65+
// a) NetDialContext, then NetDial functions used to connect to proxy
66+
// if set.
67+
// 2) Proxy: HTTP, Backend: HTTPS
68+
// a) NetDialContext, then NetDial functions used for proxy connection
69+
// if set.
70+
// b) TLSClientConfig used for backend server TLS handshake over previously
71+
// created proxy connection. (NetDialTLSContext ignored if set).
72+
// 3) Proxy: HTTPS, Backend: HTTP
73+
// a) NetDialTLSContext used to dial/TLS handshake proxy if set.
74+
// b) Otherwise if NetDialContext or NetDial are set, the are used
75+
// to create TCP connection to proxy, while TLSClientConfig is
76+
// used to perform proxy TLS handshake.
77+
// 4) Proxy: HTTPS, Backend: HTTPS
78+
// a) NetDialTLSContext used to dial/TLS handshake proxy if set.
79+
// b) Otherwise if NetDialContext or NetDial are set, the are used
80+
// to create TCP connection to proxy, while TLSClientConfig is
81+
// used to perform proxy TLS handshake.
82+
// c) TLSClientConfig is also used for backend server TLS handshake
83+
// over previously created proxy connection.
84+
//
5485
// NetDial specifies the dial function for creating TCP connections. If
5586
// NetDial is nil, net.Dialer DialContext is used.
5687
// If "Proxy" field is also set, this function dials the proxy.

0 commit comments

Comments
 (0)