Security pass

This commit is contained in:
2026-02-20 12:59:10 +00:00
parent a5a2ffd83e
commit b4d91d5dc0
3 changed files with 14 additions and 3 deletions
+7 -3
View File
@@ -4,8 +4,6 @@ import (
"net/http"
"sync"
"time"
"github.com/go-chi/chi/v5"
)
// RateLimiter implements a simple in-memory rate limiter
@@ -79,7 +77,13 @@ func RateLimit(limit int, window time.Duration) func(http.Handler) http.Handler
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Get client IP
ip := chi.URLParam(r, "X-Real-IP")
ip := r.Header.Get("CF-Connecting-IP")
if ip == "" {
ip = r.Header.Get("X-Real-IP")
}
if ip == "" {
ip = r.Header.Get("X-Forwarded-For")
}
if ip == "" {
ip = r.RemoteAddr
}