client

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2014 License: Apache-2.0 Imports: 26 Imported by: 64

Documentation

Index

Constants

View Source
const (
	CONNECT = "CONNECT" // HTTP CONNECT method

	REVERSE_PROXY_FLUSH_INTERVAL = 250 * time.Millisecond

	X_FLASHLIGHT_QOS = "X-Flashlight-QOS"

	HighQOS = 10
)
View Source
const (
	NumWorkers     = 25 // number of worker goroutines for verifying
	MaxMasquerades = 20 // cap number of verified masquerades at this
)

Variables

This section is empty.

Functions

func HttpClient

func HttpClient(serverInfo *ServerInfo, masquerade *Masquerade) *http.Client

HttpClient creates a simple domain-fronted HTTP client using the specified values for the upstream host to use and for the masquerade/domain fronted host.

Types

type ByHost

type ByHost []*ServerInfo

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 Client

type Client struct {
	// Addr: listen address in form of host:port
	Addr string

	// 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 (*Client) Configure

func (client *Client) Configure(cfg *ClientConfig, enproxyConfigs []*enproxy.Config)

Configure updates the client's configuration. Configure can be called before or after ListenAndServe, and can be called multiple times. The optional enproxyConfigs parameter allows explicitly specifying enproxy configurations for the servers in ClientConfig in lieu of building them based on the ServerInfo in ClientConfig (mostly useful for testing).

func (*Client) ListenAndServe

func (client *Client) ListenAndServe() error

ListenAndServe makes the client listen for HTTP connections

func (*Client) ServeHTTP

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

ServeHTTP implements the method from interface http.Handler

type ClientConfig

type ClientConfig struct {
	DumpHeaders    bool // whether or not to dump headers of requests and responses
	Servers        []*ServerInfo
	Peers          map[string]*nattywad.ServerPeer // keyed to peer id (e.g. XMPP JID)
	MasqueradeSets map[string][]*Masquerade
}

ClientConfig captures configuration information for a Client

func (*ClientConfig) SortServers

func (c *ClientConfig) SortServers()

SortHosts sorts the Servers array in place, ordered by host

type Masquerade

type Masquerade struct {
	// Domain: the domain to use for domain fronting
	Domain string

	// IpAddress: pre-resolved ip address to use instead of Domain (if
	// available) - NOT YET IMPLEMENTED, JUST FUTURE-PROOFING
	IpAddress string

	// RootCA: the root CA for the domain.
	RootCA string
}

Masquerade contains the data for a single masquerade host, including the domain and the root CA.

type ServerInfo

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

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

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

	// 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
	// contains filtered or unexported fields
}

ServerInfo captures configuration information for an upstream server

Jump to

Keyboard shortcuts

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