diff --git a/lib/comm.py b/lib/comm.py index 82d30e9cb0..26083e7b91 100644 --- a/lib/comm.py +++ b/lib/comm.py @@ -240,6 +240,7 @@ def decrypt(self, message, cluster_name=None, secret=None, sender_id=None): self.log.error("decrypt message from %s: %s", nodename, str(exc)) self.blacklist(sender_id) return None, None + self.blacklist_clear(sender_id) try: return nodename, json.loads(data) except ValueError as exc: @@ -302,14 +303,20 @@ def blacklist(self, sender_id): else: BLACKLIST[sender_id] = 1 - def blacklist_clear(self): + def blacklist_clear(self, sender_id=None): """ Clear the senders blacklist. """ global BLACKLIST + if sender_id is None and BLACKLIST == {}: + return with BLACKLIST_LOCK: - BLACKLIST = {} - self.log.info("blacklist cleared") + if sender_id is None: + BLACKLIST = {} + self.log.info("blacklist cleared") + elif sender_id in BLACKLIST: + del BLACKLIST[sender_id] + self.log.info("sender %s removed from blacklist") @staticmethod def get_blacklist():