Skip to content

Commit

Permalink
Merge pull request #1 from sequoiaheightsms/1.3-2
Browse files Browse the repository at this point in the history
1.3 2
  • Loading branch information
SequoiaIT-Devs authored May 17, 2024
2 parents b1f6173 + 188df8d commit 3079317
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 1 deletion.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 21 additions & 0 deletions rpmbuild/SOURCES/honeypot-probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion rpmbuild/SPECS/honeypot-blocklist.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: honeypot-blocklist
Version: 1.3
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Honeypot Blocklist Service

License: MIT License
Expand Down Expand Up @@ -103,6 +103,8 @@ systemctl daemon-reload
/etc/logrotate.d/honeypot-client

%changelog
* Thu May 16 2024 Sequoia Heights MS <[email protected]> - 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 <[email protected]> - 1.3-1
- Split into probe and client packages
- Probe: collects IPs from fail2ban and uploads to GitHub
Expand Down

0 comments on commit 3079317

Please sign in to comment.