Files
xiaolajiaoyyds 6f71df4849 Initial open-source release
多平台账号批量注册系统,支持 OpenAI / Grok / Kiro / Gemini 平台的全自动注册。

Features:
- 用户名/密码注册登录(首个用户自动管理员)
- JWT 认证 + bcrypt 密码加密
- 积分系统与多用户管理
- HuggingFace Space 弹性 Worker 节点管理
- Cloudflare Worker 负载均衡
- 实时日志推送(SSE/WebSocket)
- 管理后台(用户管理、系统设置、代理池、卡池)

Tech Stack: Go 1.25 / Gin / GORM / PostgreSQL / Vue 3 / Vite / TailwindCSS
2026-03-22 03:44:42 +08:00

52 lines
1.9 KiB
Go

package model
import (
"fmt"
"net/url"
"time"
)
// ProxyPoolEntry 全局代理池条目(管理员管理,所有用户共享)
type ProxyPoolEntry struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:100" json:"name"`
Protocol string `gorm:"size:20;not null;default:'socks5'" json:"protocol"` // socks5, http, https
Host string `gorm:"size:200;not null;uniqueIndex:idx_host_port" json:"host"`
Port int `gorm:"not null;uniqueIndex:idx_host_port" json:"port"`
Username string `gorm:"size:100" json:"username"`
Password string `gorm:"size:200" json:"password"`
Country string `gorm:"size:10" json:"country"` // 国家代码,如 US, JP
Source string `gorm:"size:50" json:"source"` // 来源:manual, imported, fetched
IsHealthy bool `gorm:"default:true;index" json:"is_healthy"`
LastCheckedAt *time.Time `json:"last_checked_at"`
LatencyMs int `gorm:"default:0" json:"latency_ms"` // 最近一次检测延迟
FailCount int `gorm:"default:0" json:"fail_count"` // 连续失败次数
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
}
// URL 生成完整代理地址(凭证经过 URL 编码,避免特殊字符破坏解析)
func (p *ProxyPoolEntry) URL() string {
u := &url.URL{
Scheme: p.Protocol,
Host: fmt.Sprintf("%s:%d", p.Host, p.Port),
}
if p.Username != "" {
u.User = url.UserPassword(p.Username, p.Password)
}
return u.String()
}
// MaskedURL 脱敏代理地址(日志用)
func (p *ProxyPoolEntry) MaskedURL() string {
auth := ""
if p.Username != "" {
auth = "***@"
}
return fmt.Sprintf("%s://%s%s:%d", p.Protocol, auth, p.Host, p.Port)
}
// HostPort 返回 host:port 格式(用于去重和 TCP 连通性检测)
func (p *ProxyPoolEntry) HostPort() string {
return fmt.Sprintf("%s:%d", p.Host, p.Port)
}