Skip to content

Commit

Permalink
Merge pull request #24 from BilikoX/master
Browse files Browse the repository at this point in the history
Do not overwrite 'X-Real IP' and 'X-Forwarded For' when coming from trusted agents other than Cloudflare
  • Loading branch information
mrinc authored Oct 4, 2024
2 parents 13a3bb3 + 547c623 commit 8725b72
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cloudflarewarp.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func (r *RealIPOverWriter) ServeHTTP(rw http.ResponseWriter, req *http.Request)
http.Error(rw, "Unknown source", http.StatusUnprocessableEntity)
return
}
if req.Header.Get(cfConnectingIP) == "" && trustResult.trusted {
req.Header.Set(xCfTrusted, "yes")
r.next.ServeHTTP(rw, req)
return
}
if trustResult.trusted {
if req.Header.Get(cfVisitor) != "" {
var cfVisitorValue CFVisitorHeader
Expand Down

0 comments on commit 8725b72

Please sign in to comment.