Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Don't rely on environment vars for proxy settings #6974
Conversation
babbageclunk
added some commits
Feb 13, 2017
|
!!chittychitty!! |
| +} | ||
| + | ||
| +// useProxy reports whether requests to addr should use a proxy, | ||
| +// according to the NO_PROXY or no_proxy environment variable. |
mjs
Feb 14, 2017
Contributor
this isn't quite right, those environment variables don't come into it here
| + | ||
| +// useProxy reports whether requests to addr should use a proxy, | ||
| +// according to the NO_PROXY or no_proxy environment variable. | ||
| +// addr is always a canonicalAddr with a host and port. |
| +func canonicalAddr(url *url.URL) string { | ||
| + addr := url.Host | ||
| + if !hasPort(addr) { | ||
| + return addr + ":" + portMap[url.Scheme] |
mjs
Feb 14, 2017
Contributor
This is technically wrong (in the stdlib too!). It generates invalid IPv6 address:port strings (we've screwed this up before). It looks like the code gets away with it because SplitHostPort allows the badly formatted values.
Use https://golang.org/pkg/net/#JoinHostPort instead
I see it's fixed upstream: https://go.googlesource.com/go/+/master/src/net/http/transport.go#1990
| + case inProcSettings = <-s.inProcSettings: | ||
| + if c.Check(inProcSettings, gc.Equals, expected) { | ||
| + gotInProc = true | ||
| + } | ||
| case <-time.After(10 * time.Millisecond): |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
jujubot
merged commit 541a664
into
juju:2.1
Feb 14, 2017
babbageclunk
deleted the
babbageclunk:proxy-settings
branch
Feb 14, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
babbageclunk commentedFeb 14, 2017
•
Edited 1 time
-
babbageclunk
Feb 14, 2017
Description of change
At the moment we update environment variables with the proxy settings,
intending for them to apply to web requests made from the running
process (like charm downloads). Unfortunately the built-in
implementation that reads proxy info from the environment only reads the
variables once - if a request has already been made the variable will
have been read and subsequent changes won't be seen.
Instead, store proxy settings in a package variable and configure the process's
default transport so it will use the values from there. Change the proxy updater
to update those config settings as well as the other places it currently sets - we
want any processes started by jujud to still get the right values in their env.
The proxy selection code was adapted from the stdlib function
net/http.ProxyFromEnvironment.QA steps
Bug reference
Fixes https://bugs.launchpad.net/juju/2.1/+bug/1654591