chore: improve proxy rate limit

code refactoring
This commit is contained in:
Jonas Kaninda
2024-10-30 04:43:05 +01:00
parent e9af89e5be
commit 5537292bc6
8 changed files with 52 additions and 43 deletions

View File

@@ -30,7 +30,7 @@ func (blockList BlockListMiddleware) BlocklistMiddleware(next http.Handler) http
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
for _, block := range blockList.List {
if isPathBlocked(r.URL.Path, util.ParseURLPath(blockList.Path+block)) {
logger.Error("Access to %s is forbidden", r.URL.Path)
logger.Warn("%s: access to %s is forbidden", getRealIP(r), r.URL.Path)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusNotFound)
err := json.NewEncoder(w).Encode(ProxyResponseError{