Commit Graph

5 Commits

Author SHA1 Message Date
brian m. carlson
81352f33fc
lfshttp/proxy: consider scheme of request URL when choosing proxy
If a user has a proxy using HTTP but a URL using HTTPS, we fail to honor
the http.proxy configuration setting because we check the scheme of the
proxy URL, not the scheme of the request URL.  Let's fix this by
deciding which proxy variable to set based on the request URL, as was
probably intended, rather than the proxy URL.

Add some tests for this case, as well as the case that we correctly
ignore the HTTPS_PROXY environment variable if the scheme of the request
URL is HTTP, which we were previously lacking.
2021-02-03 20:27:39 +00:00
brian m. carlson
8f5cd667de
lfshttp: add support for socks5h proxies
Go currently doesn't support the socks5h protocol, but it does know how
to handle it if given a URL starting with socks5:// instead.  Let's
rewrite the URLs internally to make things just magically work.
2020-09-23 16:35:27 +00:00
brian m. carlson
acd77c36f9
lfshttp: improve proxy support
Currently, our proxy support has some limitations.  Notably, we don't
handle wildcards in the no_proxy environment variable.

Unfortunately for us, there's no standard as to how these environment
variables are supposed to be handled, so any attempt we made to handle
this ourselves would likely be incomplete.  However, fortunately for us,
our needs are simple: we need standard behavior except that a user can
use a proxy for localhost, and we need to be able to read from a source
other than the environment.

The solution is to use the Go extension httpproxy module along with a
little bit of custom configuration and URL rewriting, which means we
don't have to worry about maintaining the complexity of parsing proxy
support.  This also means we can drop a large amount of complex (and
subtly wrong) code.
2020-01-07 15:45:31 +00:00
brian m. carlson
6dfe9766e0
Add support for SOCKS proxies
Currently, we prepend "http://" to the proxy URL if it's not an HTTP or
HTTPS URL. Unfortunately, that breaks support for SOCKS 5 proxies, which
use URLs that start with "socks5://". Fix this by allowing URL schemes
starting with "socks" in addition to those starting with "http".

Note that this does not introduce any support for socks5h proxies, since
Go does not support them, but we will support them automatically once Go
does.
2019-06-06 13:59:27 +00:00
Preben Ingvaldsen
d101bdb605 lfsapi: extract new lfshttp package
Extract more basic http-related functionality out of lfsapi and
into a new package, lfshttp. Everything is currently functional
aside from authorization.
2018-09-11 14:51:29 -07:00