diff --git a/RPMS/x86_64/honeypot-blocklist-client-1.3-1.el8.x86_64.rpm b/RPMS/x86_64/honeypot-blocklist-client-1.3-1.el8.x86_64.rpm deleted file mode 100644 index b969d51b..00000000 Binary files a/RPMS/x86_64/honeypot-blocklist-client-1.3-1.el8.x86_64.rpm and /dev/null differ diff --git a/RPMS/x86_64/honeypot-blocklist-client-1.3-1.el9.x86_64.rpm b/RPMS/x86_64/honeypot-blocklist-client-1.3-1.el9.x86_64.rpm deleted file mode 100644 index 30f1cf04..00000000 Binary files a/RPMS/x86_64/honeypot-blocklist-client-1.3-1.el9.x86_64.rpm and /dev/null differ diff --git a/RPMS/x86_64/honeypot-blocklist-client-1.3-2.el8.x86_64.rpm b/RPMS/x86_64/honeypot-blocklist-client-1.3-2.el8.x86_64.rpm new file mode 100644 index 00000000..edc1d420 Binary files /dev/null and b/RPMS/x86_64/honeypot-blocklist-client-1.3-2.el8.x86_64.rpm differ diff --git a/RPMS/x86_64/honeypot-blocklist-client-1.3-2.el9.x86_64.rpm b/RPMS/x86_64/honeypot-blocklist-client-1.3-2.el9.x86_64.rpm new file mode 100644 index 00000000..ae83eeeb Binary files /dev/null and b/RPMS/x86_64/honeypot-blocklist-client-1.3-2.el9.x86_64.rpm differ diff --git a/RPMS/x86_64/honeypot-blocklist-probe-1.3-1.el8.x86_64.rpm b/RPMS/x86_64/honeypot-blocklist-probe-1.3-1.el8.x86_64.rpm deleted file mode 100644 index 7ebe0d7c..00000000 Binary files a/RPMS/x86_64/honeypot-blocklist-probe-1.3-1.el8.x86_64.rpm and /dev/null differ diff --git a/RPMS/x86_64/honeypot-blocklist-probe-1.3-1.el9.x86_64.rpm b/RPMS/x86_64/honeypot-blocklist-probe-1.3-1.el9.x86_64.rpm deleted file mode 100644 index e2f1a73d..00000000 Binary files a/RPMS/x86_64/honeypot-blocklist-probe-1.3-1.el9.x86_64.rpm and /dev/null differ diff --git a/RPMS/x86_64/honeypot-blocklist-probe-1.3-2.el8.x86_64.rpm b/RPMS/x86_64/honeypot-blocklist-probe-1.3-2.el8.x86_64.rpm new file mode 100644 index 00000000..19b75859 Binary files /dev/null and b/RPMS/x86_64/honeypot-blocklist-probe-1.3-2.el8.x86_64.rpm differ diff --git a/RPMS/x86_64/honeypot-blocklist-probe-1.3-2.el9.x86_64.rpm b/RPMS/x86_64/honeypot-blocklist-probe-1.3-2.el9.x86_64.rpm new file mode 100644 index 00000000..8104f1b1 Binary files /dev/null and b/RPMS/x86_64/honeypot-blocklist-probe-1.3-2.el9.x86_64.rpm differ diff --git a/rpmbuild/SOURCES/honeypot-probe.cpp b/rpmbuild/SOURCES/honeypot-probe.cpp index a2daf796..57b9ef1b 100644 --- a/rpmbuild/SOURCES/honeypot-probe.cpp +++ b/rpmbuild/SOURCES/honeypot-probe.cpp @@ -38,8 +38,29 @@ int execWithResult(const std::string& cmd) { return result; } +// Function to check if an IP already exists in the blocklist file +bool ipExistsInBlocklist(const std::string& blocklistFile, const std::string& ip) { + std::ifstream file(blocklistFile); + if (!file.is_open()) { + throw std::runtime_error("Error opening file for reading: " + blocklistFile); + } + + std::string line; + while (std::getline(file, line)) { + if (line == ip) { + return true; // IP already exists in the blocklist + } + } + return false; +} + // Function to add an IP to the local blocklist file and commit to GitHub void addIPToBlocklist(const std::string& blocklistFile, const std::string& ip) { + if (ipExistsInBlocklist(blocklistFile, ip)) { + std::cout << "IP " << ip << " already exists in blocklist. Skipping." << std::endl; + return; + } + std::ofstream file(blocklistFile, std::ios::app); if (!file.is_open()) { throw std::runtime_error("Error opening file for writing: " + blocklistFile); diff --git a/rpmbuild/SPECS/honeypot-blocklist.spec b/rpmbuild/SPECS/honeypot-blocklist.spec index 4aa14ae5..46f3ff2c 100644 --- a/rpmbuild/SPECS/honeypot-blocklist.spec +++ b/rpmbuild/SPECS/honeypot-blocklist.spec @@ -1,6 +1,6 @@ Name: honeypot-blocklist Version: 1.3 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Honeypot Blocklist Service License: MIT License @@ -103,6 +103,8 @@ systemctl daemon-reload /etc/logrotate.d/honeypot-client %changelog +* Thu May 16 2024 Sequoia Heights MS - 1.3-2 +- Bug Fix: Explicitly check if the IP already exists in the blocklist file before adding it * Thu May 16 2024 Sequoia Heights MS - 1.3-1 - Split into probe and client packages - Probe: collects IPs from fail2ban and uploads to GitHub