client

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHTTPTimeout = time.Second * 15
)

Variables

View Source
var (
	ErrCacheRoot  = errors.New("failed to create cache root")
	ErrWriteCache = errors.New("failed to write cache")
	ErrCacheMiss  = errors.New("cached asset does not exist")
	ErrFileOpen   = errors.New("failed to open file")
	ErrGzipOpen   = errors.New("failed to open gzip file")
	ErrCopy       = errors.New("failed to copy body")
	ErrStat       = errors.New("failed to stat cached copy")
)
View Source
var (
	ErrRequestCreate    = errors.New("failed to create request")
	ErrRequestPerform   = errors.New("failed to perform request")
	ErrResponseRead     = errors.New("failed to read response body")
	ErrResponseDecode   = errors.New("failed to decode response")
	ErrResponseJSON     = errors.New("failed to generate json response")
	ErrResponseTokenize = errors.New("failed to tokenize json body")
	ErrResponseCSS      = errors.New("failed to write css body")
	ErrResponseFormat   = errors.New("failed to format body")
	ErrRateLimit        = errors.New("rate limiter error")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	MaxAge time.Duration
	// contains filtered or unexported fields
}

func New

func New(proxyProvider ProxyProvider, cache *FilesystemCache) *Client

func NewETF2LClient

func NewETF2LClient(proxyProvider ProxyProvider, cache *FilesystemCache) *Client

func NewLogsTFClient

func NewLogsTFClient(proxyProvider ProxyProvider, cache *FilesystemCache) *Client

func NewRGLClient

func NewRGLClient(proxyProvider ProxyProvider, cache *FilesystemCache) *Client

func NewRateLimit

func NewRateLimit(proxyProvider ProxyProvider, cache *FilesystemCache, limiter *rate.Limiter) *Client

func NewSteamClient

func NewSteamClient(proxyProvider ProxyProvider, keys []string, cache *FilesystemCache) *Client

func NewWithOpts

func NewWithOpts(opts HTTPClientOpts) *Client

func (*Client) Client

func (c *Client) Client() *http.Client

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do implements the same interface as http.Client. The response body *must* be closed by the caller, this is not handled automatically.

func (*Client) ProxyError

func (c *Client) ProxyError(err error) bool

func (*Client) SetRate

func (c *Client) SetRate(limiter *rate.Limiter)

func (*Client) Transport

func (c *Client) Transport() *http.Transport

func (*Client) Wait

func (c *Client) Wait(ctx context.Context) error

type FilesystemCache

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

func NewFilesystemCache

func NewFilesystemCache(root Location) *FilesystemCache

func (FilesystemCache) Read

func (f FilesystemCache) Read(url string) (io.Reader, error)

func (FilesystemCache) ReadWithExpiration

func (f FilesystemCache) ReadWithExpiration(url string, maxTime time.Duration) (io.Reader, error)

func (FilesystemCache) Write

func (f FilesystemCache) Write(url string, reader io.Reader) error

type HTTPClientOpts

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

type HTTPExecutor

type HTTPExecutor interface {
	Do(req *http.Request) (*http.Response, error)
	Client() *http.Client
	Transport() *http.Transport
	Wait(ctx context.Context) error
	ProxyError(err error) bool
}

type Location

type Location string
const (
	LocationSourcebans Location = ".cache/sourcebans"
	LocationLogsTF     Location = ".cache/logstf"
	LocationETF2L      Location = ".cache/etf2l"
	LocationRGL        Location = ".cache/rgl"
	LocationSteam      Location = ".cache/steam"
	LocationGeneral    Location = ".cache/general"
)

type NullProxyManger

type NullProxyManger struct{}

NullProxyManger implements an empty ProxyProvider for when proxies are disabled.

func (*NullProxyManger) Disconnect

func (n *NullProxyManger) Disconnect()

type ProxyConfig

type ProxyConfig struct {
	Username   string `mapstructure:"username"`
	RemoteAddr string `mapstructure:"remote_addr"`
	LocalAddr  string `mapstructure:"local_addr"`
}

type ProxyManager

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

ProxyManager handles establishing SSH socks5 tunnel connections and giving out proxy address for HTTP clients to use.

func NewProxyManager

func NewProxyManager(privateKey string, keyPassphrase string, proxyConfigs []ProxyConfig) (*ProxyManager, error)

func (*ProxyManager) Connect

func (p *ProxyManager) Connect(ctx context.Context)

func (*ProxyManager) Disconnect

func (p *ProxyManager) Disconnect()

func (*ProxyManager) Start

func (p *ProxyManager) Start(ctx context.Context)

type ProxyProvider

type ProxyProvider interface {
	Disconnect()
	// contains filtered or unexported methods
}

type QueryValueRotatorFunc

type QueryValueRotatorFunc func(r *http.Request)

Jump to

Keyboard shortcuts

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