billing: handle malformed requests

This commit is contained in:
Hay1tsme 2023-05-03 03:25:55 -04:00
parent 8d94d25893
commit 7bb8c2c80c

View File

@ -249,6 +249,7 @@ class AllnetServlet:
signer = PKCS1_v1_5.new(rsa)
digest = SHA.new()
try:
kc_playlimit = int(req_dict[0]["playlimit"])
kc_nearfull = int(req_dict[0]["nearfull"])
kc_billigtype = int(req_dict[0]["billingtype"])
@ -258,6 +259,9 @@ class AllnetServlet:
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)
if machine is None and not self.config.server.allow_unregistered_serials:
msg = f"Unrecognised serial {kc_serial} attempted billing checkin from {request_ip} for game {kc_game}."