chained

package
v7.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: GPL-3.0 Imports: 83 Imported by: 1

Documentation

Overview

Package chained provides a chained proxy that can proxy any tcp traffic over any underlying transport through a remote proxy. The downstream (client) side of the chained setup is just a dial function. The upstream (server) side is just an http.Handler. The client tells the server where to connect using an HTTP CONNECT request.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Probes determines how many times to probe on each call to Probe() unless
	// it's for performance. Should be at least 3 to generate enough packets,
	// as the censor may allow the first a few packets but block the rest.
	Probes = 3

	// PerformanceProbes determines how many times to probe for performance on
	// each call to Probe()
	PerformanceProbes = 5

	// BasePerformanceProbeKB is the minimum number of KB to request from ping
	// endpoint when probing for performance
	BasePerformanceProbeKB = 50
)
View Source
var (
	// IdleTimeout closes connections idle for a period to avoid dangling
	// connections. Web applications tend to contact servers in 1 minute
	// interval or below. 65 seconds is long enough to avoid interrupt normal
	// connections but shorter than the idle timeout on the server to avoid
	// running into closed connection problems.
	IdleTimeout = 65 * time.Second
)
View Source
var InsecureSkipVerifyTLSMasqOrigin = false

InsecureSkipVerifyTLSMasqOrigin controls whether the origin certificate is verified when dialing a tlsmasq proxy. This can be used when testing against origins with self-signed certificates. This should be false in production as allowing a 3rd party to impersonate the origin could allow for a kind of probe.

Functions

func CopyConfig

func CopyConfig(pc *config.ProxyConfig) *config.ProxyConfig

CopyConfig makes a safe copy of the config to avoid any data corruption for other users of the config.

func CopyConfigs

func CopyConfigs(proxies map[string]*config.ProxyConfig) map[string]*config.ProxyConfig

CopyConfigs makes a safe copy of the config to avoid any data corruption for other users of the config.

func CreateDialer

func CreateDialer(configDir, name string, s *config.ProxyConfig, uc common.UserConfig) (balancer.Dialer, error)

CreateDialer creates a Proxy (balancer.Dialer) with supplied server info.

func CreateDialers

func CreateDialers(configDir string, proxies map[string]*config.ProxyConfig, uc common.UserConfig) []balancer.Dialer

CreateDialers creates a list of Proxies (balancer.Dialer) with supplied server info.

func CreateDialersMap

func CreateDialersMap(configDir string, proxies map[string]*config.ProxyConfig, uc common.UserConfig) map[string]balancer.Dialer

CreateDialersMap creates a map of Proxies (balancer.Dialer) with supplied server info.

func CreateMPDialer

func CreateMPDialer(configDir, endpoint string, ss map[string]*config.ProxyConfig, uc common.UserConfig) (balancer.Dialer, error)

func ForceProxy

func ForceProxy(forceAddr string, forceToken string)

ForceProxy forces everything through the HTTP proxy at forceAddr using forceToken.

func PersistSessionStates

func PersistSessionStates(configDir string)

PersistSessionStates makes sure that session states are stored on disk in the given configDir

func TrackStatsFor

func TrackStatsFor(dialers []balancer.Dialer, configDir string, probeIfNecessary bool)

TrackStatsFor enables periodic checkpointing of the given proxies' stats to disk.

Types

type KCPConfig

type KCPConfig struct {
	kcpwrapper.DialerConfig `mapstructure:",squash"`
	RemoteAddr              string `json:"remoteaddr"`
}

KCPConfig adapts kcpwrapper.DialerConfig to the currently deployed configurations in order to provide backward-compatibility.

type Server

type Server struct {
	// Dial: function for dialing destination
	Dial func(network, address string) (net.Conn, error)
}

Server provides the upstream side of a chained proxy setup. It can be run as a standalone HTTP server using Serve() or plugged into an existing HTTP server as an http.Handler.

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve provides a convenience function for starting an HTTP server using this Server as the Handler.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP implements the method from http.Handler.

Directories

Path Synopsis
Package prefixgen defines a language for generating connection prefixes.
Package prefixgen defines a language for generating connection prefixes.

Jump to

Keyboard shortcuts

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