feat: complete rules with all shorewall columns (origdest, rate, user, mark, connlimit, time, headers, switch, helper)
This commit is contained in:
@@ -53,13 +53,24 @@ class ShorewallGenerator:
|
||||
def rules(self) -> str:
|
||||
lines = [
|
||||
self._header("rules"),
|
||||
"#ACTION".ljust(16) + "SOURCE".ljust(24) + "DEST".ljust(24) + "PROTO".ljust(10) + "DPORT".ljust(10) + "SPORT\n",
|
||||
"#ACTION".ljust(16) + "SOURCE".ljust(24) + "DEST".ljust(24)
|
||||
+ "PROTO".ljust(10) + "DPORT".ljust(16) + "SPORT".ljust(16)
|
||||
+ "ORIGDEST".ljust(20) + "RATE".ljust(16) + "USER".ljust(16)
|
||||
+ "MARK".ljust(12) + "CONNLIMIT".ljust(14) + "TIME".ljust(20)
|
||||
+ "HEADERS".ljust(16) + "SWITCH".ljust(16) + "HELPER\n",
|
||||
"SECTION NEW\n",
|
||||
]
|
||||
for r in sorted(self._config.rules, key=lambda x: x.position):
|
||||
src = (r.src_zone.name if r.src_zone else "all") + (f":{r.src_ip}" if r.src_ip else "")
|
||||
dst = (r.dst_zone.name if r.dst_zone else "all") + (f":{r.dst_ip}" if r.dst_ip else "")
|
||||
lines.append(self._col(r.action, src, dst, r.proto or "-", r.dport or "-", r.sport or "-", width=16))
|
||||
lines.append(self._col(
|
||||
r.action, src, dst,
|
||||
r.proto or "-", r.dport or "-", r.sport or "-",
|
||||
r.origdest or "-", r.rate_limit or "-", r.user_group or "-",
|
||||
r.mark or "-", r.connlimit or "-", r.time or "-",
|
||||
r.headers or "-", r.switch_name or "-", r.helper or "-",
|
||||
width=16,
|
||||
))
|
||||
return "".join(lines)
|
||||
|
||||
def hosts(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user