upstream

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles upstream proxy connections and configuration. It manages the logic for connecting to upstream servers and determining which proxy to use for each request.

func NewManager

func NewManager(upstream string, sslInsecure bool) *Manager

NewManager creates a new Manager with the given configuration. Upstream is the upstream proxy address. If empty, environment variables will be used. SslInsecure controls whether to skip SSL certificate verification.

func (*Manager) GetUpstreamConn

func (m *Manager) GetUpstreamConn(ctx context.Context, req *http.Request) (net.Conn, error)

GetUpstreamConn establishes a connection to the upstream server. It determines the appropriate proxy (if any) and creates a connection to the target server, either directly or through the proxy.

func (*Manager) GetUpstreamProxyURL

func (m *Manager) GetUpstreamProxyURL(req *http.Request) (*url.URL, error)

GetUpstreamProxyURL returns the upstream proxy URL for a given request. It checks in order: 1. Custom upstream proxy function (if set via SetUpstreamProxy) 2. Upstream field (if configured) 3. Environment variables (HTTP_PROXY, HTTPS_PROXY, etc.)

func (*Manager) RealUpstreamProxy

func (m *Manager) RealUpstreamProxy() func(*http.Request) (*url.URL, error)

RealUpstreamProxy returns a function that resolves upstream proxy for HTTP client transport. This is used by the HTTP client to determine the proxy for each request. The returned function extracts the original request from the context and uses it to determine the appropriate proxy.

func (*Manager) SetUpstreamProxy

func (m *Manager) SetUpstreamProxy(fn func(*http.Request) (*url.URL, error))

SetUpstreamProxy sets a custom upstream proxy function. This function will be called to determine the proxy URL for each request. If not set, the manager will use the config.Upstream or environment variables.

Jump to

Keyboard shortcuts

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