From e2a7d8d8e5b6cf2a731593c2f37e07a7ad9bfb8d Mon Sep 17 00:00:00 2001 From: ukrolelo <60402662+ukrolelo@users.noreply.github.com> Date: Sat, 29 May 2021 02:19:33 +0200 Subject: [PATCH] Update iptables.cpp When using default drop policy with loggin,the rule is going bellow and the log doesnt apear. with changed -I it is going above, so seperate loging for hostblock and seperate for IPs that were not blocked yet. --- hb/src/iptables.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hb/src/iptables.cpp b/hb/src/iptables.cpp index 6b6a616..652c119 100644 --- a/hb/src/iptables.cpp +++ b/hb/src/iptables.cpp @@ -73,7 +73,7 @@ bool Iptables::append(std::string chain, std::string rule) } // Prepare command - std::string cmd = "iptables -A " + chain + " " + rule; + std::string cmd = "iptables -I " + chain + " " + rule; int response = 0; if (!std::system(NULL)) { throw std::runtime_error("Command processor not available."); @@ -107,7 +107,7 @@ bool Iptables::append(std::string chain, std::vector* rules) std::string cmd; for (std::vector::iterator it = rules->begin(); it != rules->end(); ++it) { - cmd = "iptables -A " + chain + " " + *it; + cmd = "iptables -I " + chain + " " + *it; response = std::system(cmd.c_str()); if (response != 0) { throw std::runtime_error("Failed to execute iptables, returned code: " + std::to_string(response));