import dataclasses import msgpack from . import base @dataclasses.dataclass class PeerPacket(base.BasePacket): """ Represent a packet used to send information about a peer """ # public RSA key of the machine public_key: bytes = dataclasses.field(repr=False) # is the machine a master master: bool = dataclasses.field() def pack(self) -> bytes: return msgpack.packb(( self.public_key, self.master )) @classmethod def unpack(cls, data: bytes): return cls(*msgpack.unpackb(data))