Documentation ¶
Index ¶
Constants ¶
View Source
const ( // RTTErrorHappened means health check failed RTTErrorHappened = time.Hour * 24 * 365 * 99 // RTTErrorNotCheck now RTTErrorNotCheck = time.Hour * 24 * 365 * 98 )
View Source
const DefaultFastProxyHealthCheckInterval = time.Second * 60
DefaultFastProxyHealthCheckInterval is 60 seconds
View Source
const DefaultHealthCheckEndpoint = "https://www.google.com"
DefaultHealthCheckEndpoint is google
Variables ¶
View Source
var ( // ErrBackendNotProvided error ErrBackendNotProvided = errors.New("backend proxy not provided") // ErrHealthCheckStatusNotOk error ErrHealthCheckStatusNotOk = errors.New("health check response status not correct") )
Functions ¶
This section is empty.
Types ¶
type FastProxyBackendOption ¶
type FastProxyBackendOption struct { HealthCheckInterval time.Duration Backends []ProxyBackend }
FastProxyBackendOption type
type ProxyBackend ¶
type ProxyBackend interface { GetDialer() proxy.Dialer GetName() string // check dialer health, return error if anything wrong // if success, record the RTT time HealthCheck() error GetPingRTT() time.Duration IsHealth() bool }
ProxyBackend interface
func NewDialerProxyBackend ¶
func NewDialerProxyBackend(dial Dial, healthCheckEndpoint string) ProxyBackend
NewDialerProxyBackend instance
func NewDialerProxyBackendDefault ¶
func NewDialerProxyBackendDefault(dial Dial) ProxyBackend
NewDialerProxyBackendDefault instance
func NewSocks5ProxyBackend ¶
func NewSocks5ProxyBackend(opt *Socks5ProxyBackendOption) (ProxyBackend, error)
NewSocks5ProxyBackend instance
addr: a tcp address like '192.168.3.88:18080' name: the id of this socks5 proxy
type ProxyBackendProvider ¶
type ProxyBackendProvider interface { GetAll() []ProxyBackend // GetOne proxy which fastest & health GetOne() ProxyBackend }
ProxyBackendProvider interface
When create a proxy backend provider, please remember to do health check for all instance firstly
func NewFastProxyBackendProvider ¶
func NewFastProxyBackendProvider(option *FastProxyBackendOption) (ProxyBackendProvider, error)
NewFastProxyBackendProvider instance
this provider will always provide the fastest proxy backend instance
type Socks5ProxyBackendOption ¶
Socks5ProxyBackendOption type
Click to show internal directories.
Click to hide internal directories.