Documentation
¶
Index ¶
- Constants
- func Redact(value string) string
- func System() string
- 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) SetProxies(urls []string)
- func (p *Pool) Status() []Status
- type Status
Constants ¶
const Direct = "direct"
Direct 是账号固定代理中表示直连的值
Variables ¶
This section is empty.
Functions ¶
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) 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 是代理池中一个代理的当前状态与绑定的账号