Documentation
¶
Overview ¶
Package netproxy selects the outbound transport for provider HTTP traffic.
The package runs in one of two modes, decided per request:
- Managed: LiveAgent passed EnvVar at spawn or Set has been called. Providers whose useSystemProxy toggle is on use the app proxy; all others connect directly and HTTPS_PROXY/HTTP_PROXY/NO_PROXY are ignored.
- Standalone: EnvVar is unset and Set has not been called. Both toggles resolve the proxy from HTTPS_PROXY/HTTP_PROXY/NO_PROXY, matching http.DefaultTransport.
Loopback hosts are never proxied. Proxy URLs and credentials are never logged or included in errors.
Index ¶
Constants ¶
const EnvVar = "LIVEAGENT_KBRAIN_PROXY"
EnvVar carries the LiveAgent app proxy into the backend process. Values: a proxy URL (http, https, socks5, socks5h), "direct" for app proxy disabled, or "invalid" for an enabled but unusable app proxy. Any value selects managed mode; when unset the package starts in standalone mode and uses the standard HTTPS_PROXY/HTTP_PROXY/NO_PROXY variables for every provider.
Variables ¶
var ErrInvalidProxy = errors.New("app proxy is enabled but its configuration is invalid")
ErrInvalidProxy fails proxied requests while the app proxy is enabled but misconfigured, instead of silently falling back to a direct connection.
Functions ¶
func ContextTransport ¶
func ContextTransport() http.RoundTripper
ContextTransport routes each request by the toggle stored with WithProvider; requests without a mark use the toggle-off transport.
func Set ¶
Set replaces the proxy used by proxied providers and switches the package to managed mode. It applies to subsequent requests without rebuilding clients. An unparseable value is stored as invalid (proxied requests fail) and reported to the caller.
func Transport ¶
func Transport(useProxy bool) http.RoundTripper
Transport returns the cached transport for the provider toggle. In managed mode useProxy selects the app proxy or a strictly direct connection; in standalone mode both transports use the environment proxy.
Types ¶
This section is empty.