From 3d2f046dcf3481266615aa9122463ea81cb55af2 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 20 Feb 2024 11:11:00 +0300 Subject: [PATCH] refactor state hash output+filter --- pddnsc/filters/files.py | 6 +----- pddnsc/outputs/files.py | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/pddnsc/filters/files.py b/pddnsc/filters/files.py index 3330e2c..7c569be 100644 --- a/pddnsc/filters/files.py +++ b/pddnsc/filters/files.py @@ -12,11 +12,7 @@ class StateHashFilter(BaseFilterProvider): if not isfile(self.config["filepath"]): return True - new_state = { - "ipv4": addr_v4 or "", - "ipv6": addr_v6 or "", - } - new_state_str = json.dumps(new_state) + new_state_str = (addr_v4 or "") + (addr_v6 or "") new_sha = hashlib.sha256(new_state_str.encode(encoding="utf-8")) async with aiofiles.open( self.config["filepath"], mode="r", encoding="utf-8" diff --git a/pddnsc/outputs/files.py b/pddnsc/outputs/files.py index b0ab7c2..80c3bed 100644 --- a/pddnsc/outputs/files.py +++ b/pddnsc/outputs/files.py @@ -21,11 +21,7 @@ class StateFile(BaseOutputProvider): class StateHashFile(BaseOutputProvider): async def set_addrs_imp(self, source_provider, addr_v4, addr_v6): - state = { - "ipv4": addr_v4 or "", - "ipv6": addr_v6 or "", - } - state_str = json.dumps(state) + state_str = (addr_v4 or "") + (addr_v6 or "") sha = hashlib.sha256(state_str.encode(encoding="utf-8")) async with aiofiles.open( self.config["filepath"], mode="w", encoding="utf-8"