Documentation
¶
Index ¶
- Constants
- Variables
- func LoopbackHint(proxyURL string) string
- func Redact(value string) string
- func System() string
- func WithLoopbackHint(proxyURL string, err error) error
- type Pool
- func (p *Pool) Assign(accountID string) string
- func (p *Pool) Block(url string, until time.Time) []string
- func (p *Pool) Check(ctx context.Context, ...) []string
- func (p *Pool) Empty() bool
- func (p *Pool) Pick() string
- func (p *Pool) Release(accountID string)
- func (p *Pool) SetFixed(accountID string, proxyURL string)
- func (p *Pool) SetProxies(urls []string)
- func (p *Pool) Status() []Status
- type Status
Constants ¶
const Direct = "direct"
Direct 是账号固定代理中表示直连的值
Variables ¶
var InContainer = detectContainer
InContainer 报告当前进程是否运行在容器中
Functions ¶
func LoopbackHint ¶ added in v0.2.1
LoopbackHint 在容器中运行且 proxyURL 指向环回地址时返回排障说明,否则返回空
func WithLoopbackHint ¶ added in v0.2.1
WithLoopbackHint 在容器中运行且 proxyURL 指向环回地址时把排障说明附在 err 末尾,否则原样返回
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool 是未设置固定代理的账号共用的代理池:每个账号绑定一个代理,代理不可用时改绑到可用代理中账号最少的一个,代理列表变化时在可用代理间均衡
func (*Pool) Check ¶
func (p *Pool) Check(ctx context.Context, probe func(context.Context, string) (time.Duration, error)) []string
Check 以 probe 并行检测未处于人机验证停用期的全部代理并更新状态,返回绑定在不可用代理上、且有可用代理可改绑的账号
func (*Pool) SetFixed ¶ added in v0.2.1
SetFixed 登记或清除账号的固定代理:proxyURL 非空且不为 direct 时记为固定代理并解除池绑定,否则清除固定代理登记
func (*Pool) SetProxies ¶
SetProxies 替换代理列表,仍在列表中的代理保留检测结果与绑定,已删除代理上的账号改绑到账号最少的可用代理,再以最少的改绑使可用代理绑定的账号数相差不超过一个
type Status ¶
type Status struct {
URL string `json:"url"`
Healthy bool `json:"healthy"`
CheckedAt time.Time `json:"checked_at,omitzero"`
LatencyMS int64 `json:"latency_ms"`
Error string `json:"error,omitempty"`
// BlockedUntil 是出口被人机验证页拦截后停用到的时间,没有停用时省略
BlockedUntil time.Time `json:"blocked_until,omitzero"`
Accounts []string `json:"accounts"`
}
Status 是代理池中一个代理的当前状态与绑定的账号