Skip to content

Commit

Permalink
add X-Forwarded-For
Browse files Browse the repository at this point in the history
  • Loading branch information
blxdyx committed Jan 23, 2025
1 parent 800e532 commit f86596d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rpc/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
connInfo.HTTP.UserAgent = r.Header.Get("User-Agent")
ctx := r.Context()
ctx = context.WithValue(ctx, peerInfoContextKey{}, connInfo)
if xForward := r.Header.Get("X-Forwarded-For"); xForward != "" {
ctx = context.WithValue(ctx, "X-Forwarded-For", xForward)
}

// All checks passed, create a codec that reads directly from the request body
// until EOF, writes the response to w, and orders the server to process a
Expand Down

0 comments on commit f86596d

Please sign in to comment.