feat: Antigravity (googleapis.com) 也走 Node.js TLS 代理,消除 Go 指纹
Some checks failed
CI / test (push) Failing after 6m30s
CI / golangci-lint (push) Failing after 8s
Security Scan / backend-security (push) Failing after 8s
Security Scan / frontend-security (push) Failing after 6s

This commit is contained in:
win 2026-03-22 13:30:05 +08:00
parent ab1d263cf4
commit 2b7ead30be

View File

@ -124,6 +124,15 @@ func NewHTTPUpstream(cfg *config.Config) service.HTTPUpstream {
// - 调用方必须关闭 resp.Body否则会导致 inFlight 计数泄漏
// - inFlight > 0 的客户端不会被淘汰,确保活跃请求不被中断
func (s *httpUpstreamService) Do(req *http.Request, proxyURL string, accountID int64, accountConcurrency int) (*http.Response, error) {
// Node.js TLS 代理Anthropic + Google APIs无 per-account 代理时)
if s.isNodeTLSProxyEnabled() && proxyURL == "" && req != nil && req.URL != nil && req.URL.Scheme == "https" {
host := req.URL.Hostname()
if host == "api.anthropic.com" ||
strings.HasSuffix(host, ".googleapis.com") {
return s.doViaNodeTLSProxy(req, proxyURL, accountID, accountConcurrency)
}
}
if err := s.validateRequestHost(req); err != nil {
return nil, err
}
@ -175,10 +184,12 @@ func (s *httpUpstreamService) DoWithTLS(req *http.Request, proxyURL string, acco
return s.Do(req, proxyURL, accountID, accountConcurrency)
}
// 优先使用 Node.js TLS 代理模式(仅 Anthropic API 且无 per-account 代理)
// 如果账号配置了独立代理,走原有 uTLS 路径(保持代理 IP 不变)
if s.isNodeTLSProxyEnabled() && proxyURL == "" && req != nil && req.URL != nil && req.URL.Hostname() == "api.anthropic.com" {
return s.doViaNodeTLSProxy(req, proxyURL, accountID, accountConcurrency)
// 优先使用 Node.js TLS 代理模式Anthropic + Google APIs无 per-account 代理)
if s.isNodeTLSProxyEnabled() && proxyURL == "" && req != nil && req.URL != nil {
host := req.URL.Hostname()
if host == "api.anthropic.com" || strings.HasSuffix(host, ".googleapis.com") {
return s.doViaNodeTLSProxy(req, proxyURL, accountID, accountConcurrency)
}
}
// TLS 指纹已启用,记录调试日志