From 68f2353c9720e4068414a1503ed542096ce2b128 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Thu, 2 Jan 2025 17:46:28 +0200 Subject: [PATCH] Adds blacklist table --- app/classes/ratelimitrer.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/classes/ratelimitrer.php b/app/classes/ratelimitrer.php index 32f411e..0571c08 100644 --- a/app/classes/ratelimitrer.php +++ b/app/classes/ratelimitrer.php @@ -29,12 +29,23 @@ class RateLimiter { // IP whitelist table $sql = "CREATE TABLE IF NOT EXISTS {$this->whitelistTable} ( id INTEGER PRIMARY KEY AUTOINCREMENT, - ip_address TEXT NOT NULL, + ip_address TEXT NOT NULL UNIQUE, is_network BOOLEAN DEFAULT 0 CHECK(is_network IN (0,1)), description TEXT, created_at TEXT DEFAULT (DATETIME('now')), - created_by TEXT, - UNIQUE KEY unique_ip (ip_address) + created_by TEXT + )"; + $this->db->exec($sql); + + // IP blacklist table + $sql = "CREATE TABLE IF NOT EXISTS {$this->blacklistTable} ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + ip_address TEXT NOT NULL UNIQUE, + is_network BOOLEAN DEFAULT 0 CHECK(is_network IN (0,1)), + reason TEXT, + expiry_time TEXT NULL, + created_at TEXT DEFAULT (DATETIME('now')), + created_by TEXT )"; $this->db->exec($sql);