IPTables.h 1.2 KB

123456789101112131415161718192021
  1. #ifndef __IPTABLES_H
  2. #define __IPTABLES_H
  3. #include "IPAddress.h"
  4. #include "Tree.h"
  5. #include <forward_list>
  6. class IPTables
  7. {
  8. public:
  9. static const char *IPSetName(); // This is the list name that will be used in ipset to store the IPs to ban.
  10. static bool ReadFromIptables(Tree<IPAddress> &tree,bool useIpset,bool readAll); // Reads all the IPs from the iptables program.
  11. static void CreateIpsetSetname(); // // Create the ipset name. The program must already know it doesn't exist before calling.
  12. static void MakeSureIptablesHasIpsetRule(); // Make sure iptables has the right ban rule for ipset.
  13. static void BanThisIP(IPAddress &ip,bool useIpset); // Ban this IP using ipset or iptables.
  14. static void ClearCurrent(bool useIpset); // Clear the current list of IPs from iptables or ipset.
  15. static void ClearIPList(std::forward_list<IPAddress*> *ipList,bool useIpset); // Clears a list of IPs from iptables or ipset.
  16. static void BanIPsUsingRestore(std::forward_list<IPAddress*> &ipsToAddFast,bool shouldAdd); // Ban a list of IPs using ipset and restore.
  17. static IPAddress* Parse(const char *line,bool fromIPset); // Convert a line from iptables or ipset to an IPAddress object.
  18. };
  19. #endif