idac: add echo server

This commit is contained in:
2024-01-09 12:41:47 -05:00
parent 7b49a8ab58
commit 1c22c6bec0
4 changed files with 61 additions and 39 deletions

View File

@ -10,19 +10,14 @@ from titles.idac.config import IDACConfig
from titles.idac.database import IDACData
class IDACEchoUDP(DatagramProtocol):
def __init__(self, cfg: CoreConfig, game_cfg: IDACConfig, port: int) -> None:
super().__init__()
self.port = port
self.core_config = cfg
self.game_config = game_cfg
self.logger = logging.getLogger("idac")
class IDACEchoUDP:
def connection_made(self, transport):
self.transport = transport
def datagram_received(self, data, addr):
logging.getLogger('idz').debug(f'Received echo from {addr}')
self.transport.sendto(data, addr)
def datagramReceived(self, data, addr):
self.logger.info(
f"UDP Ping from from {addr[0]}:{addr[1]} -> {self.port} - {data.hex()}"
)
self.transport.write(data, addr)
class IDACEchoTCP(BaseRequestHandler):