1.2 KiB
1.2 KiB
Firewall exporters documentation
Firewall export feature is implemented trough a strategy pattern with an abstract class and a series of subclasses that implement the specific export logic for each firewall specific system:
classDiagram
class FWType{
+getBanlist()
}
FWType <|-- Raw
class Raw{ }
FWType <|-- Iptables
class Iptables{ }
note for Iptables "implements the getBanlist method for iptables rules"
Adding firewalls exporters
To add a firewall exporter create a new python class in src/firewall that implements FWType class
example with
Yourfirewallclass in theyourfirewall.pyfile
from typing_extensions import override
from firewall.fwtype import FWType
class Yourfirewall(FWType):
@override
def getBanlist(self, ips) -> str:
"""
Generate raw list of bad IP addresses.
Args:
ips: List of IP addresses to ban
Returns:
String containing raw ips, one per line
"""
if not ips:
return ""
# Add here code implementation
Then add the following to the src/server.py and src/tasks/top_attacking_ips.py
from firewall.yourfirewall import Yourfirewall