feat(proxy): add proxy module

This commit is contained in:
hzb1115
2025-11-05 21:41:36 -05:00
parent 5eae25b83e
commit 79d4dac9e5
10 changed files with 1328 additions and 0 deletions

40
proxy/types.go Normal file
View File

@@ -0,0 +1,40 @@
package proxy
import (
"net/http"
"time"
)
// ProxyIP 代理IP信息
type ProxyIP struct {
IP string `json:"ip"` // IP地址
Port string `json:"port"` // 端口(可选)
Username string `json:"username"` // 用户名(可选)
Password string `json:"password"` // 密码(可选)
Protocol string `json:"protocol"` // 协议: http, https, socks5
Ext map[string]interface{} `json:"ext"` // 扩展信息
}
// ProxyClient 代理客户端
type ProxyClient struct {
ProxyID int // IP池中的代理ID索引
IP string // 使用的IP地址
*http.Client // HTTP客户端
}
// Config 代理配置
type Config struct {
Enabled bool // 是否启用代理
Mode string // 模式: "single", "pool", "brightdata"
Timeout time.Duration // 超时时间
ProxyURL string // 单个代理地址 (single模式)
ProxyList []string // 代理列表 (pool模式)
BrightDataEndpoint string // Bright Data接口地址 (brightdata模式)
BrightDataToken string // Bright Data访问令牌 (brightdata模式)
BrightDataZone string // Bright Data区域 (brightdata模式)
ProxyHost string // 代理主机
ProxyUser string // 代理用户名模板(支持%s占位符
ProxyPassword string // 代理密码
RefreshInterval time.Duration // IP列表刷新间隔
BlacklistTTL int // 黑名单IP的TTL刷新次数
}