commit 7f5f32b8fd1d544a355da4fd1c668e4bc7f35679 Author: David Fifield david@bamsoftware.com Date: Sat May 24 20:35:56 2014 -0700
Stop implicitly taking proxy settings from the environment.
Before, if no proxy was set, we used http.DefaultTransport, which sets its proxy to the result of http.ProxyFromEnvironment(). We're going to plug proxies into the HTTP helper, which doesn't take the proxy from the environment in this way. I want the behavior to be consistent whether --helper is used or not. --- doc/meek-client.1.txt | 2 +- meek-client/meek-client.go | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/doc/meek-client.1.txt b/doc/meek-client.1.txt index d935e51..5e9e6e3 100644 --- a/doc/meek-client.1.txt +++ b/doc/meek-client.1.txt @@ -58,7 +58,7 @@ OPTIONS **--helper 127.0.0.1:7000**.
**--proxy**=__URL__:: - URL of upstream proxy. If not given, the proxy URL may be taken from the + URL of upstream proxy. The **proxy** SOCKS arg overrides the command line. For example, **--proxy=http://localhost:8787/**.
diff --git a/meek-client/meek-client.go b/meek-client/meek-client.go index c48fc69..441120f 100644 --- a/meek-client/meek-client.go +++ b/meek-client/meek-client.go @@ -101,23 +101,19 @@ type RequestInfo struct { // The Host header to put in the HTTP request (optional and may be // different from the host name in URL). Host string - // URL of an upstream proxy to use. If nil, the default net/http - // library's behavior is used, which is to check the HTTP_PROXY and - // http_proxy environment for a proxy URL. + // URL of an upstream proxy to use. If nil, no proxy is used. ProxyURL *url.URL }
// Do an HTTP roundtrip using the payload data in buf and the request metadata // in info. func roundTripWithHTTP(buf []byte, info *RequestInfo) (*http.Response, error) { - tr := http.DefaultTransport + tr := new(http.Transport) if info.ProxyURL != nil { if info.ProxyURL.Scheme != "http" { panic(fmt.Sprintf("don't know how to use proxy %s", info.ProxyURL.String())) } - tr = &http.Transport{ - Proxy: http.ProxyURL(info.ProxyURL), - } + tr.Proxy = http.ProxyURL(info.ProxyURL) } req, err := http.NewRequest("POST", info.URL.String(), bytes.NewReader(buf)) if err != nil { @@ -325,7 +321,7 @@ func main() { flag.StringVar(&options.Front, "front", "", "front domain name if no front= SOCKS arg") flag.StringVar(&helperAddr, "helper", "", "address of HTTP helper (browser extension)") flag.StringVar(&logFilename, "log", "", "name of log file") - flag.StringVar(&proxy, "proxy", "", "proxy URL (default from proxy= SOCKS arg or HTTP_PROXY environment variable)") + flag.StringVar(&proxy, "proxy", "", "proxy URL if no proxy= SOCKS arg") flag.StringVar(&options.URL, "url", "", "URL to request if no url= SOCKS arg") flag.Parse()
tor-commits@lists.torproject.org