added firewall strategy pattern

This commit is contained in:
carnivuth
2026-01-27 17:41:41 +01:00
parent b7e26f1735
commit 95dfa53e18
3 changed files with 8 additions and 6 deletions

View File

@@ -1,11 +1,10 @@
from typing_extensions import override
from firewall.fwtype import FWType
class Iptables(FWType):
@override
def getBanlist(self, ips) -> str:
def getBanlist(self,ips) -> str:
"""
Generate iptables ban rules from an array of IP addresses.
@@ -30,7 +29,11 @@ class Iptables(FWType):
ip = ip.strip()
# Build the iptables command
rule_parts = ["iptables", "-A", chain, "-s", ip]
rule_parts = [
"iptables",
"-A", chain,
"-s", ip
]
# Add target
rule_parts.extend(["-j", target])