Documentation
¶
Index ¶
- Constants
- Variables
- func Addr(timeout time.Duration) (interface{}, bool)
- func Socks5Addr(timeout time.Duration) (interface{}, bool)
- type ByHost
- type ChainedServerInfo
- type Client
- func (c *Client) Addr(timeout time.Duration) (interface{}, bool)
- func (client *Client) Configure(cfg *ClientConfig, proxyAll func() bool)
- func (client *Client) ListenAndServeHTTP(requestedAddr string, onListeningFn func()) error
- func (client *Client) ListenAndServeSOCKS5(requestedAddr string) error
- func (client *Client) ProxyAll() bool
- func (client *Client) ServeHTTP(resp http.ResponseWriter, req *http.Request)
- func (c *Client) Socks5Addr(timeout time.Duration) (interface{}, bool)
- func (client *Client) Stop() error
- type ClientConfig
- type FrontedServerInfo
Constants ¶
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 ¶
var ForceAuthToken string
If specified, auth token will be forced to this
var ForceChainedProxyAddr string
If specified, all proxying will go through this address
var ( // Address at which UI is to be found UIAddr string )
Functions ¶
func Addr ¶
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 ¶
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
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.
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 (*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 ¶
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 ¶
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.