billing: handle malformed requests

This commit is contained in:
Hay1tsme 2023-05-03 03:25:55 -04:00
parent 3b6fc6618c
commit 6d1855a6bc

View File

@ -249,14 +249,18 @@ class AllnetServlet:
signer = PKCS1_v1_5.new(rsa) signer = PKCS1_v1_5.new(rsa)
digest = SHA.new() digest = SHA.new()
kc_playlimit = int(req_dict[0]["playlimit"]) try:
kc_nearfull = int(req_dict[0]["nearfull"]) kc_playlimit = int(req_dict[0]["playlimit"])
kc_billigtype = int(req_dict[0]["billingtype"]) kc_nearfull = int(req_dict[0]["nearfull"])
kc_playcount = int(req_dict[0]["playcnt"]) kc_billigtype = int(req_dict[0]["billingtype"])
kc_serial: str = req_dict[0]["keychipid"] kc_playcount = int(req_dict[0]["playcnt"])
kc_game: str = req_dict[0]["gameid"] kc_serial: str = req_dict[0]["keychipid"]
kc_date = strptime(req_dict[0]["date"], "%Y%m%d%H%M%S") kc_game: str = req_dict[0]["gameid"]
kc_serial_bytes = kc_serial.encode() kc_date = strptime(req_dict[0]["date"], "%Y%m%d%H%M%S")
kc_serial_bytes = kc_serial.encode()
except KeyError as e:
return f"result=5&linelimit=&message={e} field is missing".encode()
machine = self.data.arcade.get_machine(kc_serial) machine = self.data.arcade.get_machine(kc_serial)
if machine is None and not self.config.server.allow_unregistered_serials: if machine is None and not self.config.server.allow_unregistered_serials: