增加解除IP封禁的选项

This commit is contained in:
huoji
2023-11-17 04:19:50 +08:00
parent 6bac06d28a
commit 4f50eee45a
7 changed files with 57 additions and 4 deletions

View File

@@ -97,6 +97,7 @@ auto IpBlacklistDB::deleteRecord(int id) -> void {
sqlite3_finalize(stmt);
}
}
// if time == 0 , it means forever
auto IpBlacklistDB::selectRecordByIpAndTime(uint32_t ip, uint64_t time_second)
-> std::optional<IpBlacklistRecord> {
std::vector<IpBlacklistRecord> records;
@@ -109,7 +110,8 @@ auto IpBlacklistDB::selectRecordByIpAndTime(uint32_t ip, uint64_t time_second)
// Adjusted SQL query to check if the timestamp is greater than or equal to
// past_time
const char *sql =
"SELECT * FROM ip_black_table WHERE ip = ? AND time >= ?;";
"SELECT * FROM ip_black_table WHERE ip = ? AND (time >= ? OR time = "
"0);";
sqlite3_stmt *stmt;
rc = sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);