proxychain

package
v1.11.1 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package proxychain dials through a chain of HTTP CONNECT forward proxies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(s string) ([]*url.URL, error)

Parse parses the proxy config value: one or more forward proxy URLs separated by whitespace, nearest hop first. An unencoded space is never valid inside a URL, so a single-proxy value parses as a one-element chain unchanged. Empty or whitespace-only input yields nil (no proxy).

Every hop must be an absolute http or https URL with a host. Errors name the offending hop by index and never echo the value, which may carry credentials.

func Redact

func Redact(u *url.URL) string

Redact renders a proxy hop as scheme://host[:port] for logs and error messages, dropping userinfo, path and query.

Types

type ConnectError

type ConnectError struct {
	Hop    string
	Next   string
	Status int
	Header http.Header
}

ConnectError is returned by the dialer when a hop answers a CONNECT with anything but 200. Hop and Next are redacted scheme://host:port strings; Header carries the hop's response headers so the caller can classify (for Envoy, x-envoy-response-flags).

func (*ConnectError) Error

func (e *ConnectError) Error() string

type DialFunc

type DialFunc func(ctx context.Context, network, addr string) (net.Conn, error)

DialFunc matches http.Transport.DialContext.

type Dialer

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

Dialer reaches addr by CONNECTing through every hop in order. The returned conn is a raw tunnel to addr; anything the caller layers on top (TLS to the target, AMQP) runs end to end through it.

func NewDialer

func NewDialer(hops []*url.URL, dial DialFunc, tlsConfig func() *tls.Config) *Dialer

NewDialer returns a Dialer over hops. dial opens the TCP connection to the first hop (nil uses a net.Dialer); tlsConfig supplies the config for https hops (nil uses the zero config).

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

DialContext returns a conn tunneled to addr through every hop.

type HopError added in v1.6.0

type HopError struct {
	Hop       string
	Handshake bool
	Err       error
}

HopError is a failure talking to a proxy hop other than a refused CONNECT. Handshake reports a failed TLS handshake with the hop; otherwise a CONNECT through the hop failed or went unanswered.

func (*HopError) Error added in v1.6.0

func (e *HopError) Error() string

func (*HopError) Unwrap added in v1.6.0

func (e *HopError) Unwrap() error

Directories

Path Synopsis
Package proxychaintest provides an in-process HTTP CONNECT forward proxy for tests.
Package proxychaintest provides an in-process HTTP CONNECT forward proxy for tests.

Jump to

Keyboard shortcuts

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