- DoWithTLS 签名变更:(bool/profile) → (TLSMode, profile) - 所有调用方传入 account.GetTLSMode() 以支持 node/utls/off 三模式 - gateway_service.go、gemini_messages_compat、forward_as_* 全部更新 - claude_usage_service 的 ClaudeUsageFetchOptions 新增 TLSMode 字段 - 新增 decompressResponseBody(gzip/brotli/deflate)到 http_upstream.go - 新增 antigravity_privacy_service.go(setAntigravityPrivacy) - admin_service 新增 ForceOpenAIPrivacy/EnsureAntigravityPrivacy/ForceAntigravityPrivacy - antigravity.Client 新增 SetUserSettings/FetchUserInfo API
37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package service
|
||
|
||
import (
|
||
"net/http"
|
||
|
||
"github.com/Wei-Shaw/sub2api/internal/pkg/tlsfingerprint"
|
||
)
|
||
|
||
// TLSMode 定义账号级别的 TLS 指纹模式
|
||
type TLSMode string
|
||
|
||
const (
|
||
// TLSModeOff 不启用 TLS 指纹,直接使用标准 Go HTTP 客户端
|
||
TLSModeOff TLSMode = "off"
|
||
// TLSModeNode 通过本地 Node.js TLS 代理发请求,天然匹配 Claude CLI 指纹
|
||
TLSModeNode TLSMode = "node"
|
||
// TLSModeUTLS 使用 uTLS 库模拟指定 Profile 的 TLS ClientHello
|
||
TLSModeUTLS TLSMode = "utls"
|
||
)
|
||
|
||
// HTTPUpstream 上游 HTTP 请求接口
|
||
// 用于向上游 API(Claude、OpenAI、Gemini 等)发送请求
|
||
type HTTPUpstream interface {
|
||
// Do 执行 HTTP 请求(不启用 TLS 指纹)
|
||
Do(req *http.Request, proxyURL string, accountID int64, accountConcurrency int) (*http.Response, error)
|
||
|
||
// DoWithTLS 执行带 TLS 指纹伪装的 HTTP 请求
|
||
//
|
||
// mode 参数决定指纹策略:
|
||
// - TLSModeOff / "": 不启用,行为与 Do 相同
|
||
// - TLSModeNode: 走本地 Node.js TLS 代理(需 gateway.node_tls_proxy.enabled=true)
|
||
// - TLSModeUTLS: 用 profile 模拟 TLS ClientHello(profile 为 nil 时降级为 Off)
|
||
//
|
||
// profile 仅在 mode=TLSModeUTLS 时生效,来自数据库或内置默认值。
|
||
DoWithTLS(req *http.Request, proxyURL string, accountID int64, accountConcurrency int, mode TLSMode, profile *tlsfingerprint.Profile) (*http.Response, error)
|
||
}
|