From 6ae11f96a29dbaea1891c7b75f23ab80057deea8 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Mon, 24 Jun 2024 22:28:22 -0400 Subject: [PATCH] aimedb: fix idm zfill issue --- core/aimedb.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/aimedb.py b/core/aimedb.py index 56490c5..88796c7 100644 --- a/core/aimedb.py +++ b/core/aimedb.py @@ -240,18 +240,19 @@ class AimedbServlette(): used on the big boy networks. """ req = ADBFelicaLookupRequest(data) - card = await self.data.card.get_card_by_idm(req.idm) + idm = req.idm.zfill(16) + card = await self.data.card.get_card_by_idm(idm) if not card: - ac = self.data.card.to_access_code(req.idm) + ac = self.data.card.to_access_code(idm) test = await self.data.card.get_card_by_access_code(ac) if test: - await self.data.card.set_idm_by_access_code(ac, req.idm) + await self.data.card.set_idm_by_access_code(ac, idm) else: ac = card['access_code'] self.logger.info( - f"idm {req.idm} ipm {req.pmm} -> access_code {ac}" + f"idm {idm} ipm {req.pmm.zfill(16)} -> access_code {ac}" ) return ADBFelicaLookupResponse.from_req(req.head, ac) @@ -293,13 +294,14 @@ class AimedbServlette(): async def handle_felica_lookup_ex(self, data: bytes, resp_code: int) -> bytes: req = ADBFelicaLookup2Request(data) user_id = None - card = await self.data.card.get_card_by_idm(req.idm) + idm = req.idm.zfill(16) + card = await self.data.card.get_card_by_idm(idm) if not card: - access_code = self.data.card.to_access_code(req.idm) + access_code = self.data.card.to_access_code(idm) card = await self.data.card.get_card_by_access_code(access_code) if card: user_id = card['user'] - await self.data.card.set_idm_by_access_code(access_code, req.idm) + await self.data.card.set_idm_by_access_code(access_code, idm) else: user_id = card['user'] @@ -309,7 +311,7 @@ class AimedbServlette(): user_id = -1 self.logger.info( - f"idm {req.idm} ipm {req.pmm} -> access_code {access_code} user_id {user_id}" + f"idm {idm} ipm {req.pmm} -> access_code {access_code} user_id {user_id}" ) resp = ADBFelicaLookup2Response.from_req(req.head, user_id, access_code)