test
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 9s

This commit is contained in:
2026-02-28 22:59:42 +01:00
parent 95d922549d
commit 5268f8dd4e

View File

@@ -58,27 +58,19 @@ class NftManager:
def list_rules_json(self) -> Dict[str, Any]: def list_rules_json(self) -> Dict[str, Any]:
""" """
Try to obtain nft -j list ruleset (JSON). Returns parsed JSON dict on success. Obtain nft -j list ruleset (JSON). Returns parsed JSON dict on success.
Raises NftError on failure or when output cannot be parsed as JSON. Raises NftError on failure or when output cannot be parsed as JSON.
""" """
cmd_variants = ["list ruleset -j", "list ruleset"] res = self.cmd("list ruleset")
last_err = None
for c in cmd_variants:
res = self.cmd(c)
if res["rc"] != 0: if res["rc"] != 0:
last_err = res["stderr"] raise NftError(f"nft list ruleset failed: {res['stderr']}")
continue
out = res["stdout"] out = res["stdout"]
if not out: if not out:
last_err = "empty output" raise NftError("nft list ruleset returned empty output")
continue
try: try:
parsed = json.loads(out) return json.loads(out)
return parsed
except json.JSONDecodeError as e: except json.JSONDecodeError as e:
last_err = f"json decode error: {e}" raise NftError(f"json decode error: {e}")
continue
raise NftError(f"unable to get JSON ruleset: {last_err}")
def list_chain_text(self, family: str, table: str, chain: str) -> str: def list_chain_text(self, family: str, table: str, chain: str) -> str:
""" """