services

package
v7.6.162 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package services provides the background services of the flashlight application. These services are responsible for fetching and updating the proxy configuration, and for reporting to the bypass server to detect if proxies are blocked. Requests to the servers are made at random intervals to prevent the thundering herd problem and help avoid detection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigHandler

type ConfigHandler interface {
	// GetConfig returns the current client config.
	GetConfig() *apipb.ConfigResponse
	// SetConfig sets the client config to the given config.
	SetConfig(new *apipb.ConfigResponse)
}

ConfigHandler handles updating and retrieving the client config.

type ConfigOptions

type ConfigOptions struct {
	// URL to use for fetching this config.
	OriginURL string

	// UserConfig contains data for communicating the user details to upstream
	// servers in HTTP headers, such as the pro token and other options.
	UserConfig common.UserConfig

	// RoundTripper provides the http.RoundTripper the fetcher should use, which allows us to
	// dictate whether the fetcher will use dual fetching (from fronted and chained URLs) or not.
	RoundTripper http.RoundTripper

	// PollInterval specifies how frequently to poll for new config.
	PollInterval time.Duration
}

ConfigOptions specifies the options to use for ConfigService.

type StopFn

type StopFn func()

func StartBypassService

func StartBypassService(
	listen func(func(map[string]*commonconfig.ProxyConfig, config.Source)),
	configDir string,
	userConfig common.UserConfig,
) StopFn

StartBypassService sends periodic traffic to the bypass server. The client periodically sends traffic to the server both via domain fronting and proxying to determine if proxies are blocked. StartBypassService returns a function to stop the service.

func StartConfigService

func StartConfigService(handler ConfigHandler, opts *ConfigOptions) (StopFn, error)

StartConfigService starts a new config service with the given options and returns a func to stop it. It will return an error if opts.OriginURL, opts.Rt, or opts.OnConfig are nil.

Jump to

Keyboard shortcuts

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