accounts

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 20 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

Overview

Package accounts 管理账号的初始化、恢复、Cookie 轮换与运行期增删

Index

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 New

func New(ctx context.Context, pool *balancer.AccountPool, settings Settings) *Manager

New 创建账号管理器,ctx 结束时全部账号停止

func (*Manager) Add

func (m *Manager) Add(account auth.LoadedAccount) error

Add 登记并启动一个新导入的账号,返回后首轮初始化结束

func (*Manager) CheckProxies added in v0.1.5

func (m *Manager) CheckProxies(ctx context.Context) []proxypool.Status

CheckProxies 检测代理池,把绑定在不可用代理上的账号与访客会话改绑到可用代理并重新初始化,返回检测后的状态

func (*Manager) ChromeAccounts

func (m *Manager) ChromeAccounts() ([]ChromeAccount, error)

ChromeAccounts 列出本机 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) IDs

func (m *Manager) IDs() []string

IDs 返回按登记顺序排列的账号 ID

func (*Manager) ImportChrome

func (m *Manager) ImportChrome(ctx context.Context, emails []string, proxy string) ([]string, error)

ImportChrome 按邮箱从本机 Chrome 导入账号并启动

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

func (m *Manager) ImportState(data []byte) (string, error)

ImportState 校验 setup --remote 上传的认证状态,写入认证目录后新增或更新账号

func (*Manager) Pool

func (m *Manager) Pool() *balancer.AccountPool

Pool 返回账号池

func (*Manager) ProxyStatus added in v0.1.5

func (m *Manager) ProxyStatus() []proxypool.Status

ProxyStatus 返回代理池中每个代理的状态

func (*Manager) Remove

func (m *Manager) Remove(accountID string) error

Remove 停止并删除账号与其认证状态文件

func (*Manager) SetEnabled

func (m *Manager) SetEnabled(accountID string, enabled bool) error

SetEnabled 启用或停用账号并写回认证状态

func (*Manager) SetProxy

func (m *Manager) SetProxy(accountID string, proxy string) error

SetProxy 修改账号固定代理并重新初始化账号,空值表示从代理池分配,direct 表示直连

func (*Manager) SetSettings

func (m *Manager) SetSettings(settings Settings)

SetSettings 修改账号配置并并行重新初始化受影响的账号:代理池变化时为分到的代理有变化的账号与访客会话,历史记录变化时为全部账号,并发设置变化时为全部账号与访客会话

func (*Manager) Settings

func (m *Manager) Settings() Settings

Settings 返回当前账号配置

func (*Manager) Start

func (m *Manager) Start(accounts []auth.LoadedAccount)

Start 登记并启动全部账号与访客会话,返回后首轮初始化全部结束

func (*Manager) Verify

func (m *Manager) Verify(accountID string) error

Verify 重新初始化账号并返回结果

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 是账号生命周期使用的配置

Jump to

Keyboard shortcuts

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