client

package
v7.6.77 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: GPL-3.0 Imports: 37 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MITMSuffixes = []string{}/* 144 elements not displayed */
View Source
var TimeoutWaitingForDNSResolutionMap = 5 * time.Second

Functions

func Addr

func Addr(timeout time.Duration) (interface{}, bool)

Addr returns the address at which the client is listening with HTTP, blocking until the given timeout for an address to become available.

func ForceProxying

func ForceProxying()

ForceProxying forces everything to get proxied (useful for testing)

func Socks5Addr

func Socks5Addr(timeout time.Duration) (interface{}, bool)

Socks5Addr returns the address at which the client is listening with SOCKS5, blocking until the given timeout for an address to become available.

func StopForcingProxying

func StopForcingProxying()

StopForcingProxying disables forced proxying (useful for testing)

Types

type Client

type Client struct {
	DNSResolutionMapForDirectDialsEventual eventual.Value
	// contains filtered or unexported fields
}

Client is an HTTP proxy that accepts connections from local programs and proxies these via remote flashlight servers.

func NewClient

func NewClient(
	configDir string,
	disconnected func() bool,
	proxyAll func() bool,
	useShortcut func() bool,
	shortcutMethod func(ctx context.Context, addr string) (shortcut.Method, net.IP),
	useDetour func() bool,
	allowHTTPSEverywhere func() bool,
	userConfig common.UserConfig,
	statsTracker stats.Tracker,
	allowPrivateHosts func() bool,
	lang func() string,
	reverseDNS func(addr string) (string, error),
	eventWithLabel func(category, action, label string),
) (*Client, error)

NewClient creates a new client that does things like starts the HTTP and SOCKS proxies. It take a function for determing whether or not to proxy all traffic, and another function to get Lantern Pro token when required.

func (*Client) Addr

func (client *Client) Addr(timeout time.Duration) (interface{}, bool)

Addr returns the address at which the client is listening with HTTP, blocking until the given timeout for an address to become available.

func (*Client) Configure

func (client *Client) Configure(proxies map[string]*commonconfig.ProxyConfig) []bandit.Dialer

Configure updates the client's configuration. Configure can be called before or after ListenAndServe, and can be called multiple times. If no error occurred, then the new dialers are returned.

func (*Client) Connect

func (client *Client) Connect(dialCtx context.Context, downstreamReader io.Reader, downstream net.Conn, origin string) error

Connects a downstream connection to the given origin and copies data bidirectionally. downstreamReader is a Reader that wraps downstream. Ideally, this is a buffered reader like from bufio.

func (*Client) ListenAndServeHTTP

func (client *Client) ListenAndServeHTTP(requestedAddr string, onListeningFn func()) error

ListenAndServeHTTP makes the client listen for HTTP connections at the given address or, if a blank address is given, at a random port on localhost. onListeningFn is a callback that gets invoked as soon as the server is accepting TCP connections. Sometimes on Windows, http.Server may fail to accept new connections after running for a random period. This method will try serve again.

func (*Client) ListenAndServeSOCKS5

func (client *Client) ListenAndServeSOCKS5(requestedAddr string) error

ListenAndServeSOCKS5 starts the SOCKS server listening at the specified address.

func (*Client) Socks5Addr

func (client *Client) Socks5Addr(timeout time.Duration) (interface{}, bool)

Socks5Addr returns the address at which the client is listening with SOCKS5, blocking until the given timeout for an address to become available.

func (*Client) Stop

func (client *Client) Stop() error

Stop is called when the client is no longer needed. It closes the client listener and underlying dialer connection pool

Jump to

Keyboard shortcuts

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