netproxy

package
v0.107.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

View Source
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

View Source
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

func Set(value string) error

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.

func WithProvider

func WithProvider(ctx context.Context, useProxy bool) context.Context

WithProvider marks ctx with the provider's proxy toggle for clients that serve several providers through one ContextTransport.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL