Documentation
¶
Overview ¶
Package accounts 管理账号的初始化、恢复、Cookie 轮换与运行期增删
Index ¶
- type ChromeAccount
- type CookieAccount
- type Manager
- func (m *Manager) Add(account auth.LoadedAccount) error
- func (m *Manager) CheckProxies(ctx context.Context) []proxypool.Status
- func (m *Manager) ChromeAccounts() ([]ChromeAccount, error)
- func (m *Manager) ChromeImporter(proxy string) func(ctx context.Context, email string) error
- func (m *Manager) DiscoverCookie(ctx context.Context, cookies string, proxy string) ([]CookieAccount, error)
- func (m *Manager) IDs() []string
- func (m *Manager) ImportCookie(ctx context.Context, cookies string, id string, proxy string, authUser int) (string, error)
- func (m *Manager) ImportState(data []byte) (string, error)
- func (m *Manager) Pool() *balancer.AccountPool
- func (m *Manager) ProxyStatus() []proxypool.Status
- func (m *Manager) Remove(accountID string) error
- func (m *Manager) SetEnabled(accountID string, enabled bool) error
- func (m *Manager) SetProxy(accountID string, proxy string) error
- func (m *Manager) SetSettings(settings Settings)
- func (m *Manager) Settings() Settings
- func (m *Manager) Start(accounts []auth.LoadedAccount)
- func (m *Manager) Verify(accountID string) error
- type Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChromeAccount ¶
type ChromeAccount struct {
chromeauth.Account
Imported bool `json:"imported"`
}
ChromeAccount 是本机 Chrome 中的一个 Google 账号及其导入状态
type CookieAccount ¶ added in v0.1.7
type CookieAccount struct {
chromeauth.CookieAccount
ID string `json:"id"`
Imported bool `json:"imported"`
}
CookieAccount 是 Cookie 中一个已登录的账号、按邮箱生成的账号 ID 及其导入状态
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 为每个账号运行初始化、失败恢复与 Cookie 轮换,并支持运行期增删
func (*Manager) Add ¶
func (m *Manager) Add(account auth.LoadedAccount) error
Add 登记并启动一个新导入的账号,返回后首轮初始化结束
func (*Manager) CheckProxies ¶ added in v0.1.5
CheckProxies 检测代理池,把绑定在不可用代理上的账号与访客会话改绑到可用代理并重新初始化,返回检测后的状态
func (*Manager) ChromeAccounts ¶
func (m *Manager) ChromeAccounts() ([]ChromeAccount, error)
ChromeAccounts 列出本机 Chrome 中可导入的账号,并标出已导入的账号
func (*Manager) ChromeImporter ¶ added in v0.1.9
ChromeImporter 返回按邮箱从本机 Chrome 导入账号并启动的函数,各次导入共用一次账号发现与主密钥读取
func (*Manager) DiscoverCookie ¶ added in v0.1.7
func (m *Manager) DiscoverCookie(ctx context.Context, cookies string, proxy string) ([]CookieAccount, error)
DiscoverCookie 识别 Cookie 中各会话登录的账号,并标出已导入的账号
func (*Manager) ImportCookie ¶
func (m *Manager) ImportCookie(ctx context.Context, cookies string, id string, proxy string, authUser int) (string, error)
ImportCookie 从 Cookie Header、浏览器导出的 JSON 或 Netscape cookies.txt 导入账号并启动
func (*Manager) ImportState ¶
ImportState 校验 setup --remote 上传的认证状态,写入认证目录后新增或更新账号
func (*Manager) ProxyStatus ¶ added in v0.1.5
ProxyStatus 返回代理池中每个代理的状态
func (*Manager) SetEnabled ¶
SetEnabled 启用或停用账号并写回认证状态
func (*Manager) SetSettings ¶
SetSettings 修改账号配置并并行重新初始化受影响的账号:代理池变化时为分到的代理有变化的账号与访客会话,历史记录变化时为全部账号,并发设置变化时为全部账号与访客会话
func (*Manager) Start ¶
func (m *Manager) Start(accounts []auth.LoadedAccount)
Start 登记并启动全部账号与访客会话,返回后首轮初始化全部结束
type Settings ¶
type Settings struct {
// InitTimeout 是单个账号一次初始化的超时
InitTimeout time.Duration
// RetryInterval 是初始化失败后再次初始化的间隔
RetryInterval time.Duration
// Proxy 是以逗号分隔的代理池,未设置固定代理的账号与访客会话从中分配
Proxy string
// SaveHistory 表示生成请求写入官网历史记录
SaveHistory bool
// AuthDir 是管理端导入的账号写入的目录
AuthDir string
// Concurrency 是每个账号同时进行的上游请求数
Concurrency int
}
Settings 是账号生命周期使用的配置