24 lines
479 B
Python
24 lines
479 B
Python
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)
|
|
|
|
def pack(self) -> bytes:
|
|
return msgpack.packb((
|
|
self.public_key,
|
|
))
|
|
|
|
@classmethod
|
|
def unpack(cls, data: bytes):
|
|
return cls(*msgpack.unpackb(data))
|