MCPcopy Index your code
hub / github.com/dnote/dnote / lookupIP

Function lookupIP

pkg/server/middleware/limit.go:107–121  ·  view source on GitHub ↗

lookupIP returns the request's IP

(r *http.Request)

Source from the content-addressed store, hash-verified

105
106// lookupIP returns the request's IP
107func lookupIP(r *http.Request) string {
108 realIP := r.Header.Get("X-Real-IP")
109 forwardedFor := r.Header.Get("X-Forwarded-For")
110
111 if forwardedFor != "" {
112 parts := strings.Split(forwardedFor, ",")
113 return parts[0]
114 }
115
116 if realIP != "" {
117 return realIP
118 }
119
120 return r.RemoteAddr
121}
122
123// Limit is a middleware to rate limit the handler
124func (rl *RateLimiter) Limit(next http.Handler) http.HandlerFunc {

Callers 2

LoggingFunction · 0.85
LimitMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected