@dataclass class Client: """Client connection information""" client_id: str address: tuple last_heartbeat: float received_chunks: int status: str ip_address: str hostname: str = "Unknown"
class GhostCastServer: """Main GhostCast Server Implementation"""
class PacketType(Enum): """GhostCast packet types""" SESSION_ANNOUNCE = 0x01 CLIENT_JOIN = 0x02 CLIENT_READY = 0x03 DATA_CHUNK = 0x04 HEARTBEAT = 0x05 COMPLETE = 0x06 ERROR = 0x07 RECOVERY_REQUEST = 0x08
@dataclass class ImagingSession: """Imaging session configuration""" session_id: str image_name: str image_size: int chunk_size: int status: SessionStatus clients: Dict[str, Client] start_time: float multicast_group: str port: int total_chunks: int current_chunk: int = 0
MAGIC_COOKIE = b'GHOST'
logging.basicConfig(level=logging.INFO) logger = logging.getLogger()
class SessionStatus(Enum): WAITING = "waiting" ACTIVE = "active" COMPLETED = "completed" FAILED = "failed"