feat: 优化代理准备并完善远端部署

- 增加严格代理、两分钟预取、白名单去重与分组状态展示\n- 增加远端注册令牌和安全地址校验\n- 增加 Docker Compose、Caddy 示例与控制中心部署文档
This commit is contained in:
yml
2026-11-21 20:59:35 +08:00
parent d176c421a8
commit 9c83be798d
43 changed files with 2755 additions and 119 deletions
+40
View File
@@ -0,0 +1,40 @@
package types
// ProxyStatusView is the structured proxy state exposed to the desktop and
// remote dashboards. Proxy credentials must never be included.
type ProxyStatusView struct {
Enabled bool `json:"enabled"`
Required bool `json:"required"`
State string `json:"state"`
ActiveCount int `json:"activeCount"`
StandbyCount int `json:"standbyCount"`
StandbyTarget int `json:"standbyTarget"`
DirectCount int `json:"directCount"`
LastError string `json:"lastError,omitempty"`
UpdatedAt string `json:"updatedAt"`
Groups []ProxyGroupStatus `json:"groups"`
Accounts []AccountProxyView `json:"accounts"`
}
// ProxyGroupStatus describes one active or standby proxy group.
type ProxyGroupStatus struct {
GroupIndex int `json:"groupIndex"`
Role string `json:"role"`
State string `json:"state"`
AccountCount int `json:"accountCount"`
Accounts []string `json:"accounts,omitempty"`
Proxy string `json:"proxy,omitempty"`
Region string `json:"region,omitempty"`
RTTMs int64 `json:"rttMs,omitempty"`
SwitchCount int `json:"switchCount"`
LastError string `json:"lastError,omitempty"`
}
// AccountProxyView maps one account to its current proxy group or direct route.
type AccountProxyView struct {
AccountName string `json:"accountName"`
GroupIndex int `json:"groupIndex,omitempty"`
GroupLabel string `json:"groupLabel"`
Transport string `json:"transport"`
Proxy string `json:"proxy,omitempty"`
}
+6 -4
View File
@@ -12,6 +12,7 @@ type SharedProxyConfig struct {
// SharedProxySettings 使用指针区分“未提供”与显式零值,支持部分配置覆盖。
type SharedProxySettings struct {
Enabled *bool `json:"enabled,omitempty"`
Required *bool `json:"required,omitempty"`
API *string `json:"api,omitempty"`
AccountsPerProxy *int `json:"accountsPerProxy,omitempty"`
SparePercent *int `json:"sparePercent,omitempty"`
@@ -25,10 +26,11 @@ type SharedProxySettings struct {
// SharedRemoteSettings 是本机或跨电脑共享的远端控制中心配置。
// 令牌会写入共享 JSON 文件,调用方必须限制该文件权限并避免外部泄露。
type SharedRemoteSettings struct {
Enabled *bool `json:"enabled,omitempty"`
URL *string `json:"url,omitempty"`
Token *string `json:"token,omitempty"`
MachineName *string `json:"machineName,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
URL *string `json:"url,omitempty"`
EnrollmentToken *string `json:"enrollmentToken,omitempty"`
Token *string `json:"token,omitempty"`
MachineName *string `json:"machineName,omitempty"`
}
// FileDialogResult 返回通过系统文件选择器选中的路径。
+4 -2
View File
@@ -18,20 +18,22 @@ type Config struct {
SeckillMode SeckillMode `json:"seckillMode"` // 抢购模式:0=标准, 1=激进
XiaodianPageSize int `json:"xiaodianPageSize"`
ProxyEnabled bool `json:"proxyEnabled"` // 是否启用代理
ProxyRequired bool `json:"proxyRequired"` // 严格代理模式:代理未就绪时不启动且不回退直连
ProxyURL string `json:"proxyUrl"` // 代理地址,支持 http://, https://, socks5://
ProxyAPI string `json:"proxyApi"` // 代理提取 API 地址,支持品赞与通用格式
SharedProxyConfigFile string `json:"sharedProxyConfigFile"` // 本机保存的共享代理配置路径
ProxyExpiresAt int64 `json:"proxyExpiresAt,omitempty"` // 当前静态代理的过期时间(Unix 毫秒),0 表示未知
AutoFetchProxyOnSchedule bool `json:"autoFetchProxyOnSchedule"` // 定时抢购触发前自动从 API 提取最新代理
AccountsPerProxy int `json:"accountsPerProxy"` // 每个独立代理承载的账号数
ProxySparePercent int `json:"proxySparePercent"` // 额外提取的备用代理比例,至少预留一个
ProxySparePercent int `json:"proxySparePercent"` // 额外提取的备用代理比例,最低和默认均为 50%
ProxyAutoWhitelist bool `json:"proxyAutoWhitelist"` // 提取前自动添加本机公网 IP 白名单
ProxyWhitelistReplace bool `json:"proxyWhitelistReplace"` // 白名单已满时替换最早 IP
ProxyWhitelistPassword string `json:"proxyWhitelistPassword"` // 白名单签名使用的登录密码
ProxyWhitelistSignKey string `json:"proxyWhitelistSignKey"` // 白名单签名使用的 AES 密钥
RemoteEnabled bool `json:"remoteEnabled"` // 是否上报远端控制中心
RemoteURL string `json:"remoteUrl"` // 远端控制中心根地址
RemoteToken string `json:"remoteToken"` // 实例连接远端使用的令牌
RemoteEnrollmentToken string `json:"remoteEnrollmentToken"` // 首次注册使用的控制中心注册令牌
RemoteToken string `json:"remoteToken"` // 兼容旧版手工实例令牌,通常留空
RemoteMachineName string `json:"remoteMachineName"` // 远端展示的机器名称,留空使用主机名
}