Skip to content

Commit 66db8f3

Browse files
committed
clarify comments and direct all proxy usage to the custom dialer
1 parent 875403e commit 66db8f3

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

internal/api/api.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ func buildTransport(opts ClientOpts, flags *Flags) http.RoundTripper {
100100
transport.TLSClientConfig = &tls.Config{}
101101
}
102102

103-
if opts.ProxyPath != "" || (opts.ProxyURL != nil && opts.ProxyURL.Scheme == "https") {
104-
// Use our custom dialer for:
105-
// - unix socket proxies
106-
// - TLS=enabled proxies, to force HTTP/1.1 for the CONNECT tunnel.
107-
// Many TLS-enabled proxy servers don't support HTTP/2 CONNECT,
108-
// which Go may negotiate via ALPN, resulting in connection errors.
103+
if opts.ProxyPath != "" || opts.ProxyURL != nil {
104+
// Use our custom dialer for proxied connections.
105+
// A custom dialer is not always needed - the connection libraries will handle HTTP(S)_PROXY-defined proxies
106+
// (Go supports http, https, socks5, and socks5h proxies via HTTP(S)_PROXY),
107+
// but we're also supporting proxies defined via SRC_PROXY, which can include UDS proxies,
108+
// and connecting to TLS-enabled proxies adds an additional wrinkle when using HTTP/2.
109109
transport = withProxyTransport(transport, opts.ProxyURL, opts.ProxyPath)
110110
}
111111

internal/api/proxy.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ func withProxyTransport(baseTransport *http.Transport, proxyURL *url.URL, proxyP
8282
baseTransport.Proxy = nil
8383
} else if proxyURL != nil {
8484
switch proxyURL.Scheme {
85-
case "socks5", "socks5h":
86-
// SOCKS proxies work out of the box - no need to manually dial
85+
case "http", "socks5", "socks5h":
86+
// HTTP and SOCKS proxies work out of the box - no need to manually dial
8787
baseTransport.Proxy = http.ProxyURL(proxyURL)
88-
case "http", "https":
88+
case "https":
8989
dial := func(ctx context.Context, network, addr string) (net.Conn, error) {
9090
// Dial the proxy. For https:// proxies, we TLS-connect to the
9191
// proxy itself and force ALPN to HTTP/1.1 to prevent Go from
@@ -166,7 +166,7 @@ func withProxyTransport(baseTransport *http.Transport, proxyURL *url.URL, proxyP
166166
}
167167
baseTransport.DialContext = dial
168168
baseTransport.DialTLSContext = dialTLS
169-
// clear out any system proxy settings
169+
// clear out the system proxy because we're defining our own dialers
170170
baseTransport.Proxy = nil
171171
}
172172
}

0 commit comments

Comments
 (0)