Skip to content

Commit

Permalink
Remove a node from the blacklist when it send a valid packet
Browse files Browse the repository at this point in the history
and its blacklist count has not yet reached the 5 limit making the node
actually blacklisted.
  • Loading branch information
cvaroqui committed Sep 8, 2017
1 parent b75e288 commit f473c78
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/comm.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit f473c78

Please sign in to comment.