Repository navigation
[probes.starlark] add probe-level proxy support - #1513
Conversation
manugarg
left a comment
There was a problem hiding this comment.
I just posted a comment about this here: #1505 (comment)
Thanks @manugarg - I've read through it and will "recalibrate" this branch/PR, as it reads as a more aligned solution, at least to me on first viewing. Watch this space 😛 Marking as Draft for now to avoid an unintended merge. |
|
Apologies for the delay @manugarg, real life got in the way a bit 😅 I've updated the title, desc, and files as part of this PR - it made sense to re-use the PR rather than close this one and create a new one, but please let me know if you'd prefer that. Also, I've removed the note about the issues I encountered when running |
|
Let me know if this doesn't correctly address your feedback on #1505 and I'll take another crack at it. |
|
Thank you so much @manugarg - I'll take a look at this shortly and address your feedback. Also, are there alternative ways to chat w/ you in a less formal manner about Cloudprober (if nothing else 😅), or would you prefer to just retain conversations on GitHub (issues, PRs, etc) at this stage? |
e4d00e2 to
01c9cdf
Compare
|
One thing worth calling out explicitly is that unifying proxy handling onto I think this is the right call for consistency between probe types, but wanted to flag it as a deliberate behaviour change rather than something that slipped in without notice. |
|
Thanks for the second pass, @manugarg -- addressed all four points. One side effect worth flagging: |
…n-blocking test send - BuildProxy: accept socks5h, which net/http's Transport supports and the http probe's proxy_url accepted before. - newTestProxy: update the comment; the loopback bypass only applies when no_proxy is set. - newTestConnectProxy: don't block the handler on a full gotHeader channel. - no_proxy: drop the incorrect HTTP-probe comparison, note the loopback bypass, and remove the trailing blank line in config.proto.
Adds probe-level HTTP proxy support to the Starlark probe using the same
proxy_urlandproxy_connect_headerfields as the HTTP probe, plus ano_proxyfield for bypassing the proxy for selected hosts.The configured proxy is applied to both the default HTTP client and every client created from
tls_configs. This allows a Starlark script to use its named TLS configuration through the proxy without adding a proxy selector to the script. The proxy function is built withcommon/httpclient.BuildProxy, which returns a plainhttp.ProxyURL-backed func by default, or one based ongolang.org/x/net/http/httpproxy.Config(standardNO_PROXYsyntax) onceno_proxyis set.When
proxy_urlis unset, existing behavior is preserved, including Go'sProxyFromEnvironmenthandling. When configured, every target is proxied, includinglocalhost/loopback, unlessno_proxyis also set -- in which caseno_proxymatching takes over, andlocalhost/loopback are then never proxied regardless ofno_proxy's contents (a quirk ofhttpproxy.Config.ProxyFunc, which hardcodes that bypass).No Starlark builtin or script changes are required.
Tests cover:
proxy_connect_headerbeing sent on the CONNECT request.no_proxybypassing the proxy for a matching host.proxy_urlis unset.Update (post-review)
Proxy construction was extracted into a shared
common/httpclient.BuildProxy, now used by thehttpandstarlarkprobes, soproxy_url/no_proxy/proxy_connect_headerbehave identically across both probe types.Also added
socks5as an acceptedproxy_urlscheme, anInit-time error whenno_proxy/proxy_connect_headerare set withoutproxy_url, credential-safe error messages for a malformedproxy_url, and rejection oftls_configscombined with anhttps://proxy_url(as both would otherwise share oneTLSClientConfigfor the proxy's own TLS handshake).Update (round 2)
Addressed review feedback:
BuildProxynow returns a plainhttp.ProxyURL(parsed)func whenno_proxyis unset, restoring thehttpprobe's original behavior of proxying every target, including loopback.httpproxy.Config(and its loopback bypass) only kicks in onceno_proxyis actually set.BuildProxynow also returns the parsed (lowercased) scheme, so thetls_configs-vs-https-proxy guard in the Starlark probe checks the parsed scheme instead of a case-sensitive string prefix (it previously missed anHTTPS://proxy URL).common/httpclient/httpclient_test.gocoveringBuildProxydirectly: the loopback-proxied default,no_proxybypass, invalid/malformed URLs (credential-safe errors), rejected schemes, and scheme normalization.httpprobe,proxy_connect_headerset withoutproxy_url, and aproxy_urlwith a scheme other thanhttp/https/socks5, now fail probeInit()instead of being silently ignored.Closes #1505.