refactor: simplified and used db.go for operations on whitelists

This commit is contained in:
2026-05-04 08:46:20 +03:30
parent 1e439f4ce3
commit ea42406c5a

View File

@@ -151,7 +151,6 @@ func logsHandler(cfg Config, db *sql.DB) http.HandlerFunc {
}
}
// --- Perm whitelist API endpoints (optional but useful) ---
func permWhitelistAddHandler(cfg Config, db *sql.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !verifyAPIKey(r, cfg.APIToken) {
@@ -159,7 +158,7 @@ func permWhitelistAddHandler(cfg Config, db *sql.DB) http.HandlerFunc {
return
}
type request struct {
Entry string `json:"entry"` // IP or CIDR
Entry string `json:"entry"`
}
var req request
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
@@ -204,7 +203,6 @@ func permWhitelistDeleteHandler(cfg Config, db *sql.DB) http.HandlerFunc {
}
}
// Helper to get real client IP for audit (X-Real-IP or remote addr)
func getClientIP(r *http.Request) string {
if ip := r.Header.Get("X-Real-IP"); ip != "" {
return ip