From fbcaab03da0f486e478f4121920339e68d3329bb Mon Sep 17 00:00:00 2001 From: win Date: Sun, 22 Mar 2026 01:36:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Node.js=20TLS=20=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E6=8C=89=20proxy=5Fhosts=20=E7=99=BD=E5=90=8D=E5=8D=95?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=20+=20=E8=AF=8A=E6=96=AD=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 proxy_hosts 配置:可配置需要走 Node.js 代理的主机列表 - 默认仅代理 api.anthropic.com,Gemini/Sora 走原路径 - 添加 warn 级别诊断日志,输出请求的 scheme/host/hostname/should_route - 用于定位 Anthropic 请求未命中 Node.js 代理的原因 --- backend/internal/repository/http_upstream.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/internal/repository/http_upstream.go b/backend/internal/repository/http_upstream.go index b5a82352..33e5bbed 100644 --- a/backend/internal/repository/http_upstream.go +++ b/backend/internal/repository/http_upstream.go @@ -125,8 +125,18 @@ func NewHTTPUpstream(cfg *config.Config) service.HTTPUpstream { // - inFlight > 0 的客户端不会被淘汰,确保活跃请求不被中断 func (s *httpUpstreamService) Do(req *http.Request, proxyURL string, accountID int64, accountConcurrency int) (*http.Response, error) { // Node.js TLS 代理:仅拦截白名单内的上游主机 - if s.isNodeTLSProxyEnabled() && s.shouldRouteViaNodeProxy(req) { - return s.doViaNodeTLSProxy(req, accountID, accountConcurrency) + if s.isNodeTLSProxyEnabled() { + if req != nil && req.URL != nil { + slog.Warn("node_tls_proxy_check", + "scheme", req.URL.Scheme, + "host", req.URL.Host, + "hostname", req.URL.Hostname(), + "should_route", s.shouldRouteViaNodeProxy(req), + ) + } + if s.shouldRouteViaNodeProxy(req) { + return s.doViaNodeTLSProxy(req, accountID, accountConcurrency) + } } if err := s.validateRequestHost(req); err != nil {