mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 18:11:32 +00:00
Implement a ZMQ prefix-match countermeasure in EHBase
This commit is contained in:
parent
558e660268
commit
17b24377dd
@ -31,10 +31,25 @@ class EventHandlerBase(ABC):
|
||||
a response back in case the handler returned something.
|
||||
This is subscribed in __init__().
|
||||
"""
|
||||
if not self.check_key(message):
|
||||
return
|
||||
|
||||
response = self.dispatch_handling(message)
|
||||
if response:
|
||||
self.server_connector.send(response)
|
||||
|
||||
def check_key(self, message):
|
||||
"""
|
||||
Checks whether the message is intended for this
|
||||
EventHandler.
|
||||
|
||||
This is necessary because ZMQ handles PUB - SUB
|
||||
connetions with pattern matching (e.g. someone
|
||||
subscribed to 'fsm' will receive 'fsm_update'
|
||||
messages as well.
|
||||
"""
|
||||
return self.key == message['key']
|
||||
|
||||
def dispatch_handling(self, message):
|
||||
"""
|
||||
Used to dispatch messages to their specific handlers.
|
||||
|
Loading…
Reference in New Issue
Block a user