From b5747d480c04e78a0128d10a0523595ee8fa82f9 Mon Sep 17 00:00:00 2001 From: jayceslesar Date: Sun, 2 Jun 2024 18:39:35 -0400 Subject: [PATCH] ??? somehow lost this??? --- masterbase/app.py | 9 ++++++--- masterbase/guards.py | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/masterbase/app.py b/masterbase/app.py index e19fd09..8a4aa45 100644 --- a/masterbase/app.py +++ b/masterbase/app.py @@ -3,7 +3,7 @@ import logging import os from datetime import datetime, timezone -from urllib.parse import urlencode +from urllib.parse import unquote, urlencode import requests import uvicorn @@ -81,8 +81,11 @@ def session_id( _session_id = generate_uuid4_int() engine = request.app.state.engine steam_id = steam_id_from_api_key(engine, api_key) - to_resolve, port = fake_ip.split(":") - fake_ip = f"{resolve_hostname(fake_ip)}:{port}" + + fake_ip = unquote(fake_ip) + if not fake_ip.startswith("169"): + to_resolve, port = fake_ip.split(":") + fake_ip = f"{resolve_hostname(fake_ip)}:{port}" start_session_helper(engine, steam_id, str(_session_id), demo_name, fake_ip, map) return {"session_id": _session_id} diff --git a/masterbase/guards.py b/masterbase/guards.py index 681fadf..1fc2c46 100644 --- a/masterbase/guards.py +++ b/masterbase/guards.py @@ -1,5 +1,7 @@ """Guards for the application.""" +from urllib.parse import unquote + from litestar.connection import ASGIConnection from litestar.exceptions import NotAuthorizedException, PermissionDeniedException from litestar.handlers.base import BaseRouteHandler @@ -85,7 +87,7 @@ async def valid_session_guard(connection: ASGIConnection, _: BaseRouteHandler) - return api_key = get_steam_api_key() - fake_ip = connection.query_params["fake_ip"] + fake_ip = unquote(connection.query_params["fake_ip"]) # 169 servers are behind SDR... if fake_ip.startswith("169"):