多平台账号批量注册系统,支持 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
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package model
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// UserProxy 用户保存的代理
|
|
type UserProxy struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
UserID uint `gorm:"not null;index" json:"user_id"`
|
|
Name string `gorm:"size:100" json:"name"`
|
|
Protocol string `gorm:"size:10;not null" json:"protocol"` // http, https, socks5
|
|
Host string `gorm:"size:200;not null" json:"host"`
|
|
Port int `gorm:"not null" json:"port"`
|
|
Username string `gorm:"size:100" json:"username"`
|
|
Password string `gorm:"size:200" json:"password"`
|
|
IsDefault bool `gorm:"default:false" json:"is_default"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
}
|
|
|
|
// URL 生成完整代理地址
|
|
func (p *UserProxy) URL() string {
|
|
auth := ""
|
|
if p.Username != "" {
|
|
auth = p.Username + ":" + p.Password + "@"
|
|
}
|
|
return fmt.Sprintf("%s://%s%s:%d", p.Protocol, auth, p.Host, p.Port)
|
|
}
|
|
|
|
// MaskedURL 脱敏代理地址(日志用)
|
|
func (p *UserProxy) MaskedURL() string {
|
|
auth := ""
|
|
if p.Username != "" {
|
|
auth = "***@"
|
|
}
|
|
return fmt.Sprintf("%s://%s%s:%d", p.Protocol, auth, p.Host, p.Port)
|
|
}
|