mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-13 17:10:36 +00:00
Fixed linting issues
This commit is contained in:
parent
8d123e47bd
commit
545856f8a0
@ -6,6 +6,8 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/bitechdev/ResolveSpec/pkg/logger"
|
||||
)
|
||||
|
||||
// IPBlacklist provides IP blocking functionality
|
||||
@ -92,7 +94,7 @@ func (bl *IPBlacklist) UnblockCIDR(cidr string) {
|
||||
}
|
||||
|
||||
// IsBlocked checks if an IP is blacklisted
|
||||
func (bl *IPBlacklist) IsBlocked(ip string) (bool, string) {
|
||||
func (bl *IPBlacklist) IsBlocked(ip string) (blacklist bool, reason string) {
|
||||
bl.mu.RLock()
|
||||
defer bl.mu.RUnlock()
|
||||
|
||||
@ -178,7 +180,10 @@ func (bl *IPBlacklist) Middleware(next http.Handler) http.Handler {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
json.NewEncoder(w).Encode(response)
|
||||
err := json.NewEncoder(w).Encode(response)
|
||||
if err != nil {
|
||||
logger.Debug("Failed to write blacklist response: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -199,6 +204,9 @@ func (bl *IPBlacklist) StatsHandler() http.Handler {
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(stats)
|
||||
err := json.NewEncoder(w).Encode(stats)
|
||||
if err != nil {
|
||||
logger.Debug("Failed to encode stats: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bitechdev/ResolveSpec/pkg/logger"
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
@ -175,7 +176,10 @@ func (rl *RateLimiter) StatsHandler() http.Handler {
|
||||
if ip := r.URL.Query().Get("ip"); ip != "" {
|
||||
info := rl.GetRateLimitInfo(ip)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(info)
|
||||
err := json.NewEncoder(w).Encode(info)
|
||||
if err != nil {
|
||||
logger.Debug("Failed to encode json: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -192,7 +196,10 @@ func (rl *RateLimiter) StatsHandler() http.Handler {
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(stats)
|
||||
err := json.NewEncoder(w).Encode(stats)
|
||||
if err != nil {
|
||||
logger.Debug("Failed to encode json: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user