From a8f5ef15503e072982f894084870aa1136815ed9 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sun, 1 Dec 2024 14:19:55 -0500 Subject: [PATCH] allnet: properly dfi encode downloadorder responses --- core/allnet.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/allnet.py b/core/allnet.py index 9eb6595..43dde1f 100644 --- a/core/allnet.py +++ b/core/allnet.py @@ -349,12 +349,22 @@ class AllnetServlet: not self.config.allnet.allow_online_updates or not self.config.allnet.update_cfg_folder ): - return PlainTextResponse(urllib.parse.unquote(urllib.parse.urlencode(vars(resp))) + "\n") + resp = urllib.parse.unquote(urllib.parse.urlencode(vars(resp))) + "\n" + if is_dfi: + return PlainTextResponse( + self.to_dfi(resp) + b"\r\n", headers={ "Pragma": "DFI" } + ) + return PlainTextResponse(resp) else: machine = await self.data.arcade.get_machine(req.serial) if not machine or not machine['ota_enable'] or not machine['is_cab'] or machine['is_blacklisted']: - return PlainTextResponse(urllib.parse.unquote(urllib.parse.urlencode(vars(resp))) + "\n") + resp = urllib.parse.unquote(urllib.parse.urlencode(vars(resp))) + "\n" + if is_dfi: + return PlainTextResponse( + self.to_dfi(resp) + b"\r\n", headers={ "Pragma": "DFI" } + ) + return PlainTextResponse(resp) if path.exists( f"{self.config.allnet.update_cfg_folder}/{req.game_id}-{req.ver.replace('.', '')}-app.ini" @@ -744,7 +754,7 @@ class AllnetDownloadOrderRequest: self.encode = req.get("encode", "") class AllnetDownloadOrderResponse: - def __init__(self, stat: int = 1, serial: str = "", uri: str = "") -> None: + def __init__(self, stat: int = 1, serial: str = "", uri: str = "null") -> None: self.stat = stat self.serial = serial self.uri = uri