Files
krawl.es/docs/firewall-exporters.md
2026-02-02 14:44:33 +01:00

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 Yourfirewall class in the yourfirewall.py file

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