client

package
v7.5.10 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: GPL-3.0 Imports: 48 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MITMSuffixes = []string{}/* 144 elements not displayed */
View Source
var SearchEnginesToTrack = map[string]SearchEngine{
	"google": {
		// contains filtered or unexported fields
	},
	"bing": {
		// contains filtered or unexported fields
	},
	"baidu": {
		// contains filtered or unexported fields
	},
}
View Source
var TimeoutWaitingForDNSResolutionMap = 5 * time.Second

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 ForceProxying

func ForceProxying()

ForceProxying forces everything to get proxied (useful for testing)

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.

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,
	allowProbes 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,
	allowMITM func() bool,
	allowGoogleSearchAds func() bool,
	userConfig common.UserConfig,
	statsTracker stats.Tracker,
	allowPrivateHosts func() bool,
	lang func() string,
	adSwapTargetURL func() string,
	reverseDNS func(addr string) (string, error),
	adTrackUrl func() string,
	eventWithLabel func(category, action, label string),
) (*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

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(proxies map[string]*commonconfig.ProxyConfig) []balancer.Dialer

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) ConfigureGoogleAds

func (client *Client) ConfigureGoogleAds(opts config.GoogleSearchAdsOptions)

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) GetBalancer

func (client *Client) GetBalancer() *balancer.Balancer

func (*Client) ListenAndServeHTTP

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

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

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

ListenAndServeSOCKS5 starts the SOCKS server listening at the specified address.

func (*Client) MITMOptions

func (c *Client) MITMOptions() *mitm.Opts

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 PartnerAd

type PartnerAd struct {
	Title       string
	Url         string
	TrackedUrl  string
	Description string
	BaseUrl     string
}

func (PartnerAd) String

func (ad PartnerAd) String(opts *config.GoogleSearchAdsOptions) string

type PartnerAds

type PartnerAds []PartnerAd

func (PartnerAds) String

func (ads PartnerAds) String(client *Client, opts *config.GoogleSearchAdsOptions) string

type SearchEngine

type SearchEngine struct {
	// contains filtered or unexported fields
}

func (*SearchEngine) Matches

func (s *SearchEngine) Matches(req *http.Request) bool

Jump to

Keyboard shortcuts

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