From b25f1f863499e21a38680d039733566fa7bee1d3 Mon Sep 17 00:00:00 2001 From: huangzhenpc Date: Mon, 25 Aug 2025 10:32:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=AE=98=E6=96=B9v0.9.0-alph?= =?UTF-8?q?a.8=EF=BC=8C=E4=BF=9D=E7=95=99=E8=87=AA=E5=AE=9A=E4=B9=89Footer?= =?UTF-8?q?=E5=92=8CClaude=E7=A9=BF=E9=80=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新到官方最新版本 (c826d06d) - 保留自定义页脚品牌信息 (听泉claude提供) - 保留Claude渠道请求穿透功能,支持PassThroughRequestEnabled设置 - 添加补丁文件便于后续维护 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- patches/claude-passthrough.patch | 45 +++++++++++++++++++++++++++++ patches/footer-custom.patch | 17 +++++++++++ relay/channel/claude/adaptor.go | 34 +++++++++++++++++----- web/src/components/layout/Footer.js | 6 ++-- 4 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 patches/claude-passthrough.patch create mode 100644 patches/footer-custom.patch diff --git a/patches/claude-passthrough.patch b/patches/claude-passthrough.patch new file mode 100644 index 00000000..0042b5e0 --- /dev/null +++ b/patches/claude-passthrough.patch @@ -0,0 +1,45 @@ +diff --git a/relay/channel/claude/adaptor.go b/relay/channel/claude/adaptor.go +index 540742d6..c715c0c9 100644 +--- a/relay/channel/claude/adaptor.go ++++ b/relay/channel/claude/adaptor.go +@@ -55,14 +55,34 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) { + } + + func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error { +- channel.SetupApiRequestHeader(info, c, req) ++ if model_setting.GetGlobalSettings().PassThroughRequestEnabled { ++ // 穿透模式:直接复制原始请求头,但跳过系统级头信息 ++ for key, values := range c.Request.Header { ++ keyLower := strings.ToLower(key) ++ if keyLower == "host" || keyLower == "content-length" || keyLower == "connection" { ++ continue ++ } ++ for _, value := range values { ++ req.Add(key, value) ++ } ++ } ++ } else { ++ // 非穿透模式:使用通用设置 ++ channel.SetupApiRequestHeader(info, c, req) ++ } ++ ++ // 无论哪种模式都需要设置正确的API密钥 + req.Set("x-api-key", info.ApiKey) +- anthropicVersion := c.Request.Header.Get("anthropic-version") +- if anthropicVersion == "" { +- anthropicVersion = "2023-06-01" ++ ++ if !model_setting.GetGlobalSettings().PassThroughRequestEnabled { ++ // 非穿透模式才强制设置这些头 ++ anthropicVersion := c.Request.Header.Get("anthropic-version") ++ if anthropicVersion == "" { ++ anthropicVersion = "2023-06-01" ++ } ++ req.Set("anthropic-version", anthropicVersion) ++ model_setting.GetClaudeSettings().WriteHeaders(info.OriginModelName, req) + } +- req.Set("anthropic-version", anthropicVersion) +- model_setting.GetClaudeSettings().WriteHeaders(info.OriginModelName, req) + return nil + } + diff --git a/patches/footer-custom.patch b/patches/footer-custom.patch new file mode 100644 index 00000000..2fee7197 --- /dev/null +++ b/patches/footer-custom.patch @@ -0,0 +1,17 @@ +diff --git a/web/src/components/layout/Footer.js b/web/src/components/layout/Footer.js +index d380e574..d20e6328 100644 +--- a/web/src/components/layout/Footer.js ++++ b/web/src/components/layout/Footer.js +@@ -82,10 +82,8 @@ const FooterBar = () => { + + +
+- {t('设计与开发由')} +- New API +- & +- One API ++ 全栈服务提供商 ++ 听泉claude提供 +
+ + diff --git a/relay/channel/claude/adaptor.go b/relay/channel/claude/adaptor.go index 540742d6..c715c0c9 100644 --- a/relay/channel/claude/adaptor.go +++ b/relay/channel/claude/adaptor.go @@ -55,14 +55,34 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) { } func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error { - channel.SetupApiRequestHeader(info, c, req) - req.Set("x-api-key", info.ApiKey) - anthropicVersion := c.Request.Header.Get("anthropic-version") - if anthropicVersion == "" { - anthropicVersion = "2023-06-01" + if model_setting.GetGlobalSettings().PassThroughRequestEnabled { + // 穿透模式:直接复制原始请求头,但跳过系统级头信息 + for key, values := range c.Request.Header { + keyLower := strings.ToLower(key) + if keyLower == "host" || keyLower == "content-length" || keyLower == "connection" { + continue + } + for _, value := range values { + req.Add(key, value) + } + } + } else { + // 非穿透模式:使用通用设置 + channel.SetupApiRequestHeader(info, c, req) + } + + // 无论哪种模式都需要设置正确的API密钥 + req.Set("x-api-key", info.ApiKey) + + if !model_setting.GetGlobalSettings().PassThroughRequestEnabled { + // 非穿透模式才强制设置这些头 + anthropicVersion := c.Request.Header.Get("anthropic-version") + if anthropicVersion == "" { + anthropicVersion = "2023-06-01" + } + req.Set("anthropic-version", anthropicVersion) + model_setting.GetClaudeSettings().WriteHeaders(info.OriginModelName, req) } - req.Set("anthropic-version", anthropicVersion) - model_setting.GetClaudeSettings().WriteHeaders(info.OriginModelName, req) return nil } diff --git a/web/src/components/layout/Footer.js b/web/src/components/layout/Footer.js index d380e574..d20e6328 100644 --- a/web/src/components/layout/Footer.js +++ b/web/src/components/layout/Footer.js @@ -82,10 +82,8 @@ const FooterBar = () => {
- {t('设计与开发由')} - New API - & - One API + 全栈服务提供商 + 听泉claude提供