HTTP and HTTPS proxies for tunnelling WebSocket connections.
To connect through a proxy, build one with new/2 and pass it as the
:proxy option to Julep.start_link/2. Its credentials are left out of
inspect/1.
Julep never reads the environment itself. To respect https_proxy,
no_proxy and the like, call resolve!/2 and pass on the result:
Julep.start_link(MyApp.Ticker, url: url, proxy: Julep.Proxy.resolve!(url))
Summary
Types
Functions
Builds a proxy from a URL such as "http://user:secret@proxy.internal:3128".
Returns :error unless the URL has an http or https scheme and a host.
Options
:tls_opts- TLS options for the connection to anhttpsproxy, merged over Mint's defaults. Ignored for anhttpproxy. Defaults to[].
@spec resolve(String.t(), env: env(), tls_opts: keyword()) :: resolution()
Resolves the proxy for a ws:// or wss:// URL from the environment.
Returns {:ok, proxy} when a proxy applies, :none when the URL should be
reached directly, and :error when the variable that applies does not hold
an http or https proxy URL, as for new/2.
Follows the conventions of curl and most HTTP clients:
- A
wss://URL useshttps_proxy, thenhttp_proxy, thenall_proxy. Aws://URL useshttp_proxy, thenall_proxy. - A lowercase variable wins over its uppercase form, and an empty value counts as unset.
no_proxyis a comma-separated list of hosts to reach directly, ignoring case.*matches every host. A name matches itself and its subdomains, with or without a leading.or*.. An IP address matches the same address however it is written, so::1matches0:0:0:0:0:0:0:1.- An address range, such as
10.0.0.0/8orfd00::/8, matches a URL whose host is an address inside it. Names are never resolved to check them against a range. - A
no_proxyentry with a port, such asexample.com:8443or[::1]:8443, matches that port only.
Options
:env- the environment to read, as a map of variable names to values. Defaults toSystem.get_env/0.:tls_opts- TLS options for the resolved proxy, as fornew/2.
Resolves the proxy for a URL from the environment, as resolve/2 does.
Returns the proxy, or nil when the URL should be reached directly. Raises
where resolve/2 returns :error.
Takes the options of resolve/2.