From 66c9548dd260d3a64b0876abe2f3f429f2dfe84c Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Mon, 22 Jan 2024 15:03:59 -0500 Subject: [PATCH] mucha: move to starlette --- core/mucha.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/core/mucha.py b/core/mucha.py index 0559983..488e5dc 100644 --- a/core/mucha.py +++ b/core/mucha.py @@ -47,15 +47,16 @@ class MuchaServlet: self.logger.info(f"Serving {len(self.mucha_registry)} games") - def handle_boardauth(self, request: Request) -> bytes: - req_dict = self.mucha_preprocess(request.content.getvalue()) + async def handle_boardauth(self, request: Request) -> bytes: + req_raw = await request.body() + req_dict = self.mucha_preprocess(req_raw) client_ip = Utils.get_ip_addr(request) if req_dict is None: self.logger.error( - f"Error processing mucha request {request.content.getvalue()}" + f"Error processing mucha boardauth request {req_raw}" ) - return b"RESULTS=000" + return b"" req = MuchaAuthRequest(req_dict) self.logger.info(f"Boardauth request from {client_ip} for {req.gameVer}") @@ -82,15 +83,16 @@ class MuchaServlet: return self.mucha_postprocess(vars(resp)) - def handle_updatecheck(self, request: Request) -> bytes: - req_dict = self.mucha_preprocess(request.content.getvalue()) + async def handle_updatecheck(self, request: Request) -> bytes: + req_raw = await request.body() + req_dict = self.mucha_preprocess(req_raw) client_ip = Utils.get_ip_addr(request) if req_dict is None: self.logger.error( - f"Error processing mucha request {request.content.getvalue()}" + f"Error processing mucha updatecheck request {req_raw}" ) - return b"RESULTS=000" + return b"" req = MuchaUpdateRequest(req_dict) self.logger.info(f"Updatecheck request from {client_ip} for {req.gameVer}") @@ -106,13 +108,14 @@ class MuchaServlet: return self.mucha_postprocess(vars(resp)) - def handle_dlstate(self, request: Request) -> bytes: - req_dict = self.mucha_preprocess(request.content.getvalue()) + async def handle_dlstate(self, request: Request) -> bytes: + req_raw = await request.body() + req_dict = self.mucha_preprocess(req_raw) client_ip = Utils.get_ip_addr(request) if req_dict is None: self.logger.error( - f"Error processing mucha request {request.content.getvalue()}" + f"Error processing mucha dlstate request {req_raw}" ) return b""