From 2b7ead30be4d6e4f7fffbbcd12723eca085a5631 Mon Sep 17 00:00:00 2001 From: win Date: Sun, 22 Mar 2026 13:30:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Antigravity=20(googleapis.com)=20?= =?UTF-8?q?=E4=B9=9F=E8=B5=B0=20Node.js=20TLS=20=E4=BB=A3=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E6=B6=88=E9=99=A4=20Go=20=E6=8C=87=E7=BA=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/repository/http_upstream.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/backend/internal/repository/http_upstream.go b/backend/internal/repository/http_upstream.go index 6e97e192..d90a1755 100644 --- a/backend/internal/repository/http_upstream.go +++ b/backend/internal/repository/http_upstream.go @@ -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 指纹已启用,记录调试日志