fix: 有 per-account 代理的账号不走 Node.js 代理,防止 IP 变化触发风控
This commit is contained in:
parent
fba8cc82ae
commit
e909214ee5
@ -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 == "" {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user