from source import packets from source.behaviors import roles from source.behaviors.events import base class KeyEvent(base.BaseTrustedEvent): """ Event reacting to a machine sending us their secret key """ def handle(self, packet: packets.KeyPacket, address: tuple): super().handle(packet, address) # check if we are a slave if not isinstance(self.manager.role.current, roles.SlaveRole): return # TODO(Faraphel): check if this come from our server ? # use the secret key for further symmetric communication self.manager.role.current.secret_key = packet.secret_key