Add a line to remove the rule first, in case it already existed
This commit is contained in:
parent
629894c29c
commit
161ea0eaf4
@ -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<<std::format("New offender {} detected and added to banlist!",ipAddr)<<std::endl;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user