client

package
v0.0.0-...-fd97e0e Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2016 License: Apache-2.0, Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LanternSpecialDomain is a special domain for use by lantern that gets
	// resolved to localhost by the proxy
	LanternSpecialDomain          = "ui.lantern.io"
	LanternSpecialDomainWithColon = "ui.lantern.io:"
)

Variables

View Source
var ForceAuthToken string

If specified, auth token will be forced to this

View Source
var ForceChainedProxyAddr string

If specified, all proxying will go through this address

View Source
var (

	// Address at which UI is to be found
	UIAddr string
)

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 Socks5Addr

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

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

Types

type ByHost

type ByHost []*FrontedServerInfo

ByHost implements sort.Interface for []*ServerInfo based on the host

func (ByHost) Len

func (a ByHost) Len() int

func (ByHost) Less

func (a ByHost) Less(i, j int) bool

func (ByHost) Swap

func (a ByHost) Swap(i, j int)

type ChainedServerInfo

type ChainedServerInfo struct {
	// Addr: the host:port of the upstream proxy server
	Addr string

	// Pipelined: If true, requests to the chained server will be pipelined
	Pipelined bool

	// Cert: optional PEM encoded certificate for the server. If specified,
	// server will be dialed using TLS over tcp. Otherwise, server will be
	// dialed using plain tcp.
	Cert string

	// AuthToken: the authtoken to present to the upstream server.
	AuthToken string

	// Weight: relative weight versus other servers (for round-robin)
	Weight int

	// QOS: relative quality of service offered. Should be >= 0, with higher
	// values indicating higher QOS.
	QOS int

	// Trusted: Determines if a host can be trusted with plain HTTP traffic.
	Trusted bool
}

ChainedServerInfo provides identity information for a chained server.

func (*ChainedServerInfo) Dialer

func (s *ChainedServerInfo) Dialer(deviceID string) (*balancer.Dialer, error)

Dialer creates a *balancer.Dialer backed by a chained server.

type Client

type Client struct {
	// ReadTimeout: (optional) timeout for read ops
	ReadTimeout time.Duration

	// WriteTimeout: (optional) timeout for write ops
	WriteTimeout time.Duration
	// 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() *Client

func (*Client) Addr

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

func (*Client) Configure

func (client *Client) Configure(cfg *ClientConfig, proxyAll func() bool)

Configure updates the client's configuration. Configure can be called before or after ListenAndServe, and can be called multiple times.

func (*Client) ListenAndServeHTTP

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

ListenAndServe makes the client listen for HTTP connections at a 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.

func (*Client) ListenAndServeSOCKS5

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

func (*Client) ProxyAll

func (client *Client) ProxyAll() bool

func (*Client) ServeHTTP

func (client *Client) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP implements the method from interface http.Handler using the latest handler available from getHandler() and latest ReverseProxy available from getReverseProxy().

func (*Client) Socks5Addr

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

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

type ClientConfig

type ClientConfig struct {
	// MinQOS: (optional) the minimum QOS to require from proxies.
	MinQOS int

	// Unique identifier for this device
	DeviceID string

	// List of CONNECT ports that are proxied via the remote proxy. Other ports
	// will be handled with direct connections.
	ProxiedCONNECTPorts []int

	DumpHeaders    bool // whether or not to dump headers of requests and responses
	FrontedServers []*FrontedServerInfo
	ChainedServers map[string]*ChainedServerInfo
	MasqueradeSets map[string][]*fronted.Masquerade
}

ClientConfig captures configuration information for a Client

func (*ClientConfig) SortServers

func (c *ClientConfig) SortServers()

SortServers sorts the Servers array in place, ordered by host

type FrontedServerInfo

type FrontedServerInfo struct {
	// Host: the host (e.g. getiantem.org)
	Host string

	// Port: the port (e.g. 443)
	Port int

	// PoolSize: size of connection pool to use. 0 disables connection pooling.
	PoolSize int

	// MasqueradeSet: the name of the masquerade set from ClientConfig that
	// contains masquerade hosts to use for this server.
	MasqueradeSet string

	// MaxMasquerades: the maximum number of masquerades to verify. If 0,
	// the masquerades are uncapped.
	MaxMasquerades int

	// InsecureSkipVerify: if true, server's certificate is not verified.
	InsecureSkipVerify bool

	// BufferRequests: if true, requests to the proxy will be buffered and sent
	// with identity encoding.  If false, they'll be streamed with chunked
	// encoding.
	BufferRequests bool

	// DialTimeoutMillis: how long to wait on dialing server before timing out
	// (defaults to 5 seconds)
	DialTimeoutMillis int

	// RedialAttempts: number of times to try redialing. The total number of
	// dial attempts will be 1 + RedialAttempts.
	RedialAttempts int

	// Weight: relative weight versus other servers (for round-robin)
	Weight int

	// QOS: relative quality of service offered. Should be >= 0, with higher
	// values indicating higher QOS.
	QOS int

	// Trusted: Determines if a host can be trusted with unencrypted HTTP
	// traffic.
	Trusted bool
}

FrontedServerInfo captures configuration information for an upstream domain- fronted server.

Jump to

Keyboard shortcuts

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