From 6d1855a6bc910d9a042b8bb4c1c220d958d4be05 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Wed, 3 May 2023 03:25:55 -0400 Subject: [PATCH 1/3] billing: handle malformed requests --- core/allnet.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/core/allnet.py b/core/allnet.py index 119f0ae..ab435e7 100644 --- a/core/allnet.py +++ b/core/allnet.py @@ -249,14 +249,18 @@ class AllnetServlet: signer = PKCS1_v1_5.new(rsa) digest = SHA.new() - kc_playlimit = int(req_dict[0]["playlimit"]) - kc_nearfull = int(req_dict[0]["nearfull"]) - kc_billigtype = int(req_dict[0]["billingtype"]) - kc_playcount = int(req_dict[0]["playcnt"]) - kc_serial: str = req_dict[0]["keychipid"] - kc_game: str = req_dict[0]["gameid"] - kc_date = strptime(req_dict[0]["date"], "%Y%m%d%H%M%S") - kc_serial_bytes = kc_serial.encode() + try: + kc_playlimit = int(req_dict[0]["playlimit"]) + kc_nearfull = int(req_dict[0]["nearfull"]) + kc_billigtype = int(req_dict[0]["billingtype"]) + kc_playcount = int(req_dict[0]["playcnt"]) + kc_serial: str = req_dict[0]["keychipid"] + kc_game: str = req_dict[0]["gameid"] + 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: From d0242b456db2cce1d3c98097ecd68158d6e854e4 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Wed, 3 May 2023 22:29:08 -0400 Subject: [PATCH 2/3] mai2: fix for dx 1.00 --- titles/mai2/base.py | 9 ++++++++- titles/mai2/index.py | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/titles/mai2/base.py b/titles/mai2/base.py index 171378c..44ec60d 100644 --- a/titles/mai2/base.py +++ b/titles/mai2/base.py @@ -16,8 +16,15 @@ class Mai2Base: self.version = Mai2Constants.VER_MAIMAI_DX self.data = Mai2Data(cfg) self.logger = logging.getLogger("mai2") + + if self.core_config.server.is_develop and self.core_config.title.port > 0: + self.old_server = f"http://{self.core_config.title.hostname}:{self.core_config.title.port}/SDEY/100/" + + else: + self.old_server = f"http://{self.core_config.title.hostname}/SDEY/100/" def handle_get_game_setting_api_request(self, data: Dict): + # TODO: See if making this epoch 0 breaks things reboot_start = date.strftime( datetime.now() + timedelta(hours=3), Mai2Constants.DATE_TIME_FORMAT ) @@ -34,7 +41,7 @@ class Mai2Base: "movieStatus": 0, "movieServerUri": "", "deliverServerUri": "", - "oldServerUri": "", + "oldServerUri": self.old_server, "usbDlServerUri": "", "rebootInterval": 0, }, diff --git a/titles/mai2/index.py b/titles/mai2/index.py index 1b92842..3326843 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -82,13 +82,13 @@ class Mai2Servlet: return ( True, f"http://{core_cfg.title.hostname}:{core_cfg.title.port}/{game_code}/$v/", - f"{core_cfg.title.hostname}:{core_cfg.title.port}/", + f"{core_cfg.title.hostname}:{core_cfg.title.port}", ) return ( True, f"http://{core_cfg.title.hostname}/{game_code}/$v/", - f"{core_cfg.title.hostname}/", + f"{core_cfg.title.hostname}", ) def render_POST(self, request: Request, version: int, url_path: str) -> bytes: From efd8f86e48e533d7bfd96c6be6b69bda78783af7 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Thu, 4 May 2023 09:46:16 -0400 Subject: [PATCH 3/3] re-add docker files for #19 --- Dockerfile | 21 +++++++++++++++++ docker-compose.yml | 57 ++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 11 +++++++++ 3 files changed, 89 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e34dfec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.9.15-slim-bullseye + +RUN apt update && apt install default-libmysqlclient-dev build-essential libtk nodejs npm -y + +WORKDIR /app +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt +RUN npm i -g nodemon + +COPY entrypoint.sh entrypoint.sh +RUN chmod +x entrypoint.sh + +COPY index.py index.py +COPY dbutils.py dbutils.py +ADD core core +ADD titles titles +ADD config config +ADD log log +ADD cert cert + +ENTRYPOINT [ "/app/entrypoint.sh" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c43b6e5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,57 @@ +version: "3.9" +services: + app: + hostname: ma.app + build: . + volumes: + - ./aime:/app/aime + + environment: + CFG_DEV: 1 + CFG_CORE_SERVER_HOSTNAME: 0.0.0.0 + CFG_CORE_DATABASE_HOST: ma.db + CFG_CORE_MEMCACHED_HOSTNAME: ma.memcached + CFG_CORE_AIMEDB_KEY: keyhere + CFG_CHUNI_SERVER_LOGLEVEL: debug + + ports: + - "80:80" + - "8443:8443" + - "22345:22345" + + - "8080:8080" + - "8090:8090" + + depends_on: + db: + condition: service_healthy + + db: + hostname: ma.db + image: mysql:8.0.31-debian + environment: + MYSQL_DATABASE: aime + MYSQL_USER: aime + MYSQL_PASSWORD: aime + MYSQL_ROOT_PASSWORD: AimeRootPassword + healthcheck: + test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] + timeout: 5s + retries: 5 + + + memcached: + hostname: ma.memcached + image: memcached:1.6.17-bullseye + + phpmyadmin: + hostname: ma.phpmyadmin + image: phpmyadmin:latest + environment: + PMA_HOSTS: ma.db + PMA_USER: root + PMA_PASSWORD: AimeRootPassword + APACHE_PORT: 8080 + ports: + - "8080:8080" + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..aa95ca8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [[ -z "${CFG_DEV}" ]]; then + echo Production mode + python3 index.py +else + echo Development mode + python3 dbutils.py create + nodemon -w aime --legacy-watch index.py +fi +