Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit 8725b72

Browse files
authored
Merge pull request #24 from BilikoX/master
Do not overwrite 'X-Real IP' and 'X-Forwarded For' when coming from trusted agents other than Cloudflare
2 parents 13a3bb3 + 547c623 commit 8725b72

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: cloudflarewarp.go

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ func (r *RealIPOverWriter) ServeHTTP(rw http.ResponseWriter, req *http.Request)
9999
http.Error(rw, "Unknown source", http.StatusUnprocessableEntity)
100100
return
101101
}
102+
if req.Header.Get(cfConnectingIP) == "" && trustResult.trusted {
103+
req.Header.Set(xCfTrusted, "yes")
104+
r.next.ServeHTTP(rw, req)
105+
return
106+
}
102107
if trustResult.trusted {
103108
if req.Header.Get(cfVisitor) != "" {
104109
var cfVisitorValue CFVisitorHeader

0 commit comments

Comments
 (0)