Initial commit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
谢宇宁
2026-09-29 11:47:47 +07:00
co-authored by Claude Opus 5.5
commit 0fbdba5ccf
622 changed files with 72105 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package http
import "strings"
// ApplyClientForwardHeaders 向上游透传客户端 IP 与浏览器 UA。
func ApplyClientForwardHeaders(header map[string]string, clientIP, userAgent string) {
if header == nil {
return
}
if ip := strings.TrimSpace(clientIP); ip != "" {
header["X-Real-IP"] = ip
}
if ua := strings.TrimSpace(userAgent); ua != "" {
header["User-Agent"] = ua
}
}
// ApplyClientForwardHeadersWithXUA 透传 IP、浏览器 UA,以及可选的 X-User-Agent。
func ApplyClientForwardHeadersWithXUA(header map[string]string, clientIP, userAgent, xUserAgent string) {
ApplyClientForwardHeaders(header, clientIP, userAgent)
if header == nil {
return
}
if xua := strings.TrimSpace(xUserAgent); xua != "" {
header["X-User-Agent"] = xua
}
}