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

This commit is contained in:
2026-02-28 22:20:43 +01:00
parent 3a5eb0a46d
commit 49e6e30a87

View File

@@ -61,24 +61,10 @@ class NftManager:
Try to obtain nft -j list ruleset (JSON). Returns parsed JSON dict on success. Try to 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.nft.json_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 return res["stdout"]
out = res["stdout"]
if not out:
last_err = "empty output"
continue
try:
parsed = json.loads(out)
return parsed
except json.JSONDecodeError as e:
last_err = 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:
""" """