proxypool

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const Direct = "direct"

Direct 是账号固定代理中表示直连的值

Variables

This section is empty.

Functions

func Redact

func Redact(value string) string

Redact 返回隐去密码的代理 URL

func System

func System() string

System 返回环境变量或操作系统设置中作用于 Gemini 的代理 URL,没有设置时返回空

Types

type Pool

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

Pool 是未设置固定代理的账号共用的代理池:每个账号绑定一个代理,代理不可用时改绑到可用代理中账号最少的一个,代理列表变化时在可用代理间均衡

func New

func New(urls []string) *Pool

New 创建代理池,代理在首次检测前视为可用

func (*Pool) Assign

func (p *Pool) Assign(accountID string) string

Assign 返回账号使用的代理:已绑定的代理可用时沿用,否则绑定可用代理中账号最少的一个;全部不可用时保持原绑定,代理池为空时返回系统代理

func (*Pool) Check

func (p *Pool) Check(ctx context.Context, probe func(context.Context, string) (time.Duration, error)) []string

Check 以 probe 并行检测全部代理并更新状态,返回绑定在不可用代理上、且有可用代理可改绑的账号

func (*Pool) Empty

func (p *Pool) Empty() bool

Empty 报告代理池是否没有代理

func (*Pool) Pick

func (p *Pool) Pick() string

Pick 返回可用代理中账号最少的一个且不绑定,代理池为空时返回系统代理

func (*Pool) Release

func (p *Pool) Release(accountID string)

Release 解除账号与代理的绑定

func (*Pool) SetProxies

func (p *Pool) SetProxies(urls []string)

SetProxies 替换代理列表,仍在列表中的代理保留检测结果与绑定,已删除代理上的账号改绑到账号最少的可用代理,再以最少的改绑使可用代理绑定的账号数相差不超过一个

func (*Pool) Status

func (p *Pool) Status() []Status

Status 返回代理池中每个代理的状态,代理 URL 隐去密码

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"`
	Accounts  []string  `json:"accounts"`
}

Status 是代理池中一个代理的当前状态与绑定的账号

Jump to

Keyboard shortcuts

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