20 lines
734 B
Python
20 lines
734 B
Python
from . import base
|
|
from source import packets
|
|
from .. import roles
|
|
from ...utils.crypto.type import CipherType
|
|
|
|
|
|
class DiscoveryEvent(base.BaseEvent):
|
|
"""
|
|
Event reacting to a machine trying to discover the network.
|
|
"""
|
|
|
|
def handle(self, packet: packets.DiscoveryPacket, address: tuple):
|
|
# create a peer packet containing our important information
|
|
response = packets.PeerPacket(
|
|
self.manager.communication.public_key,
|
|
isinstance(self.manager.role.current, roles.MasterRole)
|
|
)
|
|
# send our information back
|
|
# don't use any encryption to share the RSA key for further communication
|
|
self.manager.communication.send(response, CipherType.PLAIN, address)
|