Skip to content

Commit 995704a

Browse files
committed
clarify comments and direct all proxy usage to the custom dialer
1 parent 280d0c6 commit 995704a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

internal/api/api.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ func buildTransport(opts ClientOpts, flags *Flags) *http.Transport {
9797
transport.TLSClientConfig = &tls.Config{}
9898
}
9999

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

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)