client

package
v0.0.0-...-8b1022e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2016 License: Apache-2.0, Apache-2.0 Imports: 33 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"
)

Variables

View Source
var ForceAuthToken string

ForceAuthToken - If specified, auth token will be forced to this

View Source
var ForceChainedProxyAddr string

ForceChainedProxyAddr - If specified, all proxying will go through this address

View Source
var (

	// UIAddr is the 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 ChainedDialer

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

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

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.

Types

type ChainedServerInfo

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

	// 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. For OBFS4 proxies, this is the Base64-encoded obfs4
	// certificate.
	Cert string

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

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

	// PluggableTransport: If specified, a pluggable transport will be used
	PluggableTransport string

	// PluggableTransportSettings: Settings for pluggable transport
	PluggableTransportSettings map[string]string
}

ChainedServerInfo contains all the data for connecting to a given 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(proxyAll func() bool) *Client

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.

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(cfg *ClientConfig, deviceID string)

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

ListenAndServeHTTP 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

ListenAndServeSOCKS5 starts the SOCKS server listening at the specified address.

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 (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

type ClientConfig

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

	// 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
	ChainedServers map[string]*ChainedServerInfo
	MasqueradeSets map[string][]*fronted.Masquerade
}

ClientConfig captures configuration information for a Client

Jump to

Keyboard shortcuts

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