From e909214ee510c0fa4285ef4bf487041a0e643d51 Mon Sep 17 00:00:00 2001 From: win Date: Sun, 22 Mar 2026 11:33:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9C=89=20per-account=20=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E7=9A=84=E8=B4=A6=E5=8F=B7=E4=B8=8D=E8=B5=B0=20Node.j?= =?UTF-8?q?s=20=E4=BB=A3=E7=90=86=EF=BC=8C=E9=98=B2=E6=AD=A2=20IP=20?= =?UTF-8?q?=E5=8F=98=E5=8C=96=E8=A7=A6=E5=8F=91=E9=A3=8E=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/repository/http_upstream.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/internal/repository/http_upstream.go b/backend/internal/repository/http_upstream.go index 9daf80be..d72d4006 100644 --- a/backend/internal/repository/http_upstream.go +++ b/backend/internal/repository/http_upstream.go @@ -175,10 +175,10 @@ func (s *httpUpstreamService) DoWithTLS(req *http.Request, proxyURL string, acco return s.Do(req, proxyURL, accountID, accountConcurrency) } - // 优先使用 Node.js TLS 代理模式(仅 Anthropic API) - // 其他上游(Sora/Bedrock 等)需要 Chrome 指纹,走原有 uTLS 路径 - if s.isNodeTLSProxyEnabled() && req != nil && req.URL != nil && req.URL.Hostname() == "api.anthropic.com" { - return s.doViaNodeTLSProxy(req, 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) } // TLS 指纹已启用,记录调试日志 @@ -273,7 +273,7 @@ func (s *httpUpstreamService) shouldRouteViaNodeProxy(req *http.Request) bool { // 由 Node.js 进程使用原生 TLS 栈完成到上游的 HTTPS 连接。 // 原始目标主机通过 X-Forwarded-Host 传递给 Node.js 代理, // 代理据此动态连接到正确的上游主机。 -func (s *httpUpstreamService) doViaNodeTLSProxy(req *http.Request, accountID int64, accountConcurrency int) (*http.Response, error) { +func (s *httpUpstreamService) doViaNodeTLSProxy(req *http.Request, proxyURL string, accountID int64, accountConcurrency int) (*http.Response, error) { proxyCfg := s.cfg.Gateway.NodeTLSProxy listenHost := proxyCfg.ListenHost if listenHost == "" {