summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-03-16 11:44:08 +0100
committerAnton Khirnov <anton@khirnov.net>2024-03-16 11:44:08 +0100
commitb5ede905a4471a8239883c4ec3cc03fba8ec686e (patch)
treeb2b569abb562b9cbdf7792f352e5ba58b9dd9be0
parent58abdc976ba9c28b3ab095f999e442afc8e0a6e1 (diff)
Handle JSON decode errors when processing events.HEADmaster
Seems nftrace events produce non-JSON data even with nft -j.
-rwxr-xr-xnaros.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/naros.py b/naros.py
index a77cd7f..0e38563 100755
--- a/naros.py
+++ b/naros.py
@@ -653,7 +653,13 @@ class NftMonitor:
def process(self, process_cb):
for line in self._child.stdout:
- cmd, val = nft_json_pop(json.loads(line))
+ try:
+ data = json.loads(line)
+ except json.decoder.JSONDecodeError:
+ self._logger.error('Error decoding event: %s', line)
+ continue
+
+ cmd, val = nft_json_pop(data)
self._logger.debug('Nft event: %s %s', cmd, val)