Documentation ¶
Index ¶
- Variables
- func Addr(timeout time.Duration) (interface{}, bool)
- func ForceProxying()
- func Socks5Addr(timeout time.Duration) (interface{}, bool)
- func StopForcingProxying()
- type Client
- func (client *Client) Addr(timeout time.Duration) (interface{}, bool)
- func (client *Client) Configure(proxies map[string]*commonconfig.ProxyConfig) []dialer.ProxyDialer
- func (client *Client) Connect(dialCtx context.Context, downstreamReader io.Reader, downstream net.Conn, ...) error
- func (client *Client) ListenAndServeHTTP(requestedAddr string, onListeningFn func()) error
- func (client *Client) ListenAndServeSOCKS5(requestedAddr string) error
- func (client *Client) Socks5Addr(timeout time.Duration) (interface{}, bool)
- func (client *Client) Stop() error
Constants ¶
This section is empty.
Variables ¶
var TimeoutWaitingForDNSResolutionMap = 5 * time.Second
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 ForceProxying ¶
func ForceProxying()
ForceProxying forces everything to get proxied (useful for testing)
func Socks5Addr ¶
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), onDialError func(error, bool), onSucceedingProxy func(), ) (*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 ¶
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) []dialer.ProxyDialer
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 ¶
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 ¶
ListenAndServeSOCKS5 starts the SOCKS server listening at the specified address.
func (*Client) Socks5Addr ¶
Socks5Addr returns the address at which the client is listening with SOCKS5, blocking until the given timeout for an address to become available.