diff --git a/.env.example b/.env.example index 85846fc0..175b56a8 100644 --- a/.env.example +++ b/.env.example @@ -51,6 +51,9 @@ REDIRECT_OSU_URLS=True PP_CACHED_ACCS=90,95,98,99,100 +ALLOW_MCOSU_CLIENTS=True +ALLOW_MCOSU_SCORES=False + DISALLOWED_NAMES=mrekk,vaxei,btmc,cookiezi DISALLOWED_PASSWORDS=password,abc123 DISALLOW_OLD_CLIENTS=True diff --git a/app/api/domains/cho.py b/app/api/domains/cho.py index 29790114..24bceda3 100644 --- a/app/api/domains/cho.py +++ b/app/api/domains/cho.py @@ -186,9 +186,21 @@ async def bancho_handler( request: Request, osu_token: str | None = Header(None), user_agent: Literal["osu!"] = Header(...), + x_mcosu_ver: str | None = Header(None), ) -> Response: ip = app.state.services.ip_resolver.get_ip(request.headers) + if x_mcosu_ver is not None and app.settings.ALLOW_MCOSU_CLIENTS is False: + return Response( + headers={"cho-token": "no"}, + content=( + app.packets.login_reply(LoginFailureReason.AUTHENTICATION_FAILED) + + app.packets.notification( + "McOsu clients are not allowed on this server.", + ) + ), + ) + if osu_token is None: # the client is performing a login login_data = await handle_osu_login_request( @@ -199,7 +211,10 @@ async def bancho_handler( return Response( content=login_data["response_body"], - headers={"cho-token": login_data["osu_token"]}, + headers={ + "cho-token": login_data["osu_token"], + "x-mcosu-features": f"submit={1 if app.settings.ALLOW_MCOSU_SCORES else 0}", + }, ) # get the player from the specified osu token. diff --git a/app/settings.py b/app/settings.py index aa292197..bb381bd9 100644 --- a/app/settings.py +++ b/app/settings.py @@ -50,6 +50,9 @@ PP_CACHED_ACCURACIES = [int(acc) for acc in read_list(os.environ["PP_CACHED_ACCS"])] +ALLOW_MCOSU_CLIENTS = read_bool(os.environ["ALLOW_MCOSU_CLIENTS"]) +ALLOW_MCOSU_SCORES = read_bool(os.environ["ALLOW_MCOSU_SCORES"]) + DISALLOWED_NAMES = read_list(os.environ["DISALLOWED_NAMES"]) DISALLOWED_PASSWORDS = read_list(os.environ["DISALLOWED_PASSWORDS"]) DISALLOW_OLD_CLIENTS = read_bool(os.environ["DISALLOW_OLD_CLIENTS"])