From 766912c51d3a35e9fc1d7ed8606bc39956cfcf65 Mon Sep 17 00:00:00 2001 From: zaphkito Date: Tue, 18 Jun 2024 03:13:32 +0000 Subject: [PATCH 1/2] ongeki: fix base version title work --- titles/ongeki/index.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/titles/ongeki/index.py b/titles/ongeki/index.py index d7f3e0e..f91bf8f 100644 --- a/titles/ongeki/index.py +++ b/titles/ongeki/index.py @@ -216,16 +216,20 @@ class OngekiServlet(BaseServlet): ) return Response(zlib.compress(b'{"stat": "0"}')) - try: - unzip = zlib.decompress(req_raw) + if version < 105: + # O.N.G.E.K.I base don't use zlib + req_data = req_raw + else: + try: + unzip = zlib.decompress(req_raw) + + except zlib.error as e: + self.logger.error( + f"Failed to decompress v{version} {endpoint} request -> {e}" + ) + return Response(zlib.compress(b'{"stat": "0"}')) - except zlib.error as e: - self.logger.error( - f"Failed to decompress v{version} {endpoint} request -> {e}" - ) - return Response(zlib.compress(b'{"stat": "0"}')) - - req_data = json.loads(unzip) + req_data = json.loads(unzip) self.logger.info( f"v{version} {endpoint} request from {client_ip}" @@ -251,9 +255,12 @@ class OngekiServlet(BaseServlet): self.logger.debug(f"Response {resp}") - zipped = zlib.compress(json.dumps(resp, ensure_ascii=False).encode("utf-8")) + resp_raw = json.dumps(resp, ensure_ascii=False).encode("utf-8") + zipped = zlib.compress(resp_raw) if not encrtped or version < 120: + if version < 105: + return Response(resp_raw) return Response(zipped) padded = pad(zipped, 16) From 51f65f9293020a0cefd0520638688ae82de95691 Mon Sep 17 00:00:00 2001 From: zaphkito Date: Tue, 18 Jun 2024 04:15:40 +0000 Subject: [PATCH 2/2] ongeki: I forgot json load --- titles/ongeki/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titles/ongeki/index.py b/titles/ongeki/index.py index f91bf8f..3bd0e15 100644 --- a/titles/ongeki/index.py +++ b/titles/ongeki/index.py @@ -218,7 +218,7 @@ class OngekiServlet(BaseServlet): if version < 105: # O.N.G.E.K.I base don't use zlib - req_data = req_raw + req_data = json.loads(req_raw) else: try: unzip = zlib.decompress(req_raw)