Initial commit

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
fish03
2026-09-23 14:43:16 +07:00
co-authored by Claude Opus 5.5
commit bef9f8b4ed
663 changed files with 81305 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
}
}