feat: add hosts and params files, fix rules SECTION NEW header
All checks were successful
Build containers when image tags change / build-if-image-changed (backend, shorefront-backend, shorefront backend, backend/Dockerfile, git.baumann.gr/adebaumann/shorefront-backend, .backend.image) (push) Successful in 44s
Build containers when image tags change / build-if-image-changed (frontend, shorefront-frontend, shorefront frontend, frontend/Dockerfile, git.baumann.gr/adebaumann/shorefront-frontend, .frontend.image) (push) Successful in 1m32s
All checks were successful
Build containers when image tags change / build-if-image-changed (backend, shorefront-backend, shorefront backend, backend/Dockerfile, git.baumann.gr/adebaumann/shorefront-backend, .backend.image) (push) Successful in 44s
Build containers when image tags change / build-if-image-changed (frontend, shorefront-frontend, shorefront frontend, frontend/Dockerfile, git.baumann.gr/adebaumann/shorefront-frontend, .frontend.image) (push) Successful in 1m32s
This commit is contained in:
@@ -41,6 +41,7 @@ class ShorewallGenerator:
|
||||
lines = [
|
||||
self._header("rules"),
|
||||
"#ACTION".ljust(16) + "SOURCE".ljust(24) + "DEST".ljust(24) + "PROTO".ljust(10) + "DPORT".ljust(10) + "SPORT\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 "")
|
||||
@@ -48,6 +49,19 @@ class ShorewallGenerator:
|
||||
lines.append(self._col(r.action, src, dst, r.proto or "-", r.dport or "-", r.sport or "-", width=16))
|
||||
return "".join(lines)
|
||||
|
||||
def hosts(self) -> str:
|
||||
lines = [self._header("hosts"), "#ZONE".ljust(16) + "HOSTS\n"]
|
||||
for h in self._config.host_entries:
|
||||
hosts_val = f"{h.interface}:{h.subnet}"
|
||||
lines.append(self._col(h.zone.name, hosts_val, h.options or "-", width=16))
|
||||
return "".join(lines)
|
||||
|
||||
def params(self) -> str:
|
||||
lines = [self._header("params")]
|
||||
for p in self._config.params:
|
||||
lines.append(f"{p.name}={p.value}\n")
|
||||
return "".join(lines)
|
||||
|
||||
def snat(self) -> str:
|
||||
lines = [self._header("snat"), "#ACTION".ljust(24) + "SOURCE".ljust(24) + "DEST\n"]
|
||||
for m in self._config.snat_entries:
|
||||
@@ -62,6 +76,8 @@ class ShorewallGenerator:
|
||||
"policy": self.policy(),
|
||||
"rules": self.rules(),
|
||||
"snat": self.snat(),
|
||||
"hosts": self.hosts(),
|
||||
"params": self.params(),
|
||||
}
|
||||
|
||||
def as_zip(self) -> bytes:
|
||||
@@ -72,4 +88,6 @@ class ShorewallGenerator:
|
||||
zf.writestr("policy", self.policy())
|
||||
zf.writestr("rules", self.rules())
|
||||
zf.writestr("snat", self.snat())
|
||||
zf.writestr("hosts", self.hosts())
|
||||
zf.writestr("params", self.params())
|
||||
return buf.getvalue()
|
||||
|
||||
Reference in New Issue
Block a user