MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / clientIP

Function clientIP

internal/httpapi/ratelimit.go:147–155  ·  view source on GitHub ↗

clientIP extracts the caller IP for per-IP limiting. It trusts only CF-Connecting-IP (set by Cloudflare and stripped from inbound requests at the edge), NOT X-Forwarded-For: an attacker can prepend an arbitrary XFF entry and Cloudflare appends the real client IP rather than replacing it, so the left

(r *http.Request)

Source from the content-addressed store, hash-verified

145// to XFF. Mirrors agent.clientIP and oauth dcrSourceIP so every per-IP
146// limiter keys identically.
147func clientIP(r *http.Request) string {
148 if ip := strings.TrimSpace(r.Header.Get("CF-Connecting-IP")); ip != "" {
149 return ip
150 }
151 if host, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {
152 return host
153 }
154 return r.RemoteAddr
155}

Callers 3

rateLimitMethod · 0.70

Calls 1

GetMethod · 0.65

Tested by 1