From 161ea0eaf4d37ba03d5064e222e07363bcb323c7 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 22 Apr 2025 14:09:01 -0500 Subject: [PATCH] Add a line to remove the rule first, in case it already existed --- GiteaBlocker/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/GiteaBlocker/main.cpp b/GiteaBlocker/main.cpp index bb12293..254b8fd 100644 --- a/GiteaBlocker/main.cpp +++ b/GiteaBlocker/main.cpp @@ -68,6 +68,7 @@ int main(){ user.totalHits++; if(user.totalHits>tooFrequentAccess){ ipBanList.insert(ipAddr); + std::system(std::format("iptables -D INPUT -s {} -j DROP",ipAddr).c_str()); //In case the rule already existed, we are going to remove it first... No effect if it does not exist. std::system(std::format("iptables -I INPUT 1 -s {} -j DROP",ipAddr).c_str()); std::cout<