from objects.score import Score from constants.modes import lbModes, osuModes from constants.statuses import mapStatuses, scoreStatuses from constants.mods import Mods from constants.privs import Privileges from constants.flags import osuFlags from objects.leaderboard import Leaderboard from constants import regexes from packets import writer ss_path = Path.cwd() / 'resources/screenshots' vn_path = Path.cwd() / 'resources/replays' rx_path = Path.cwd() / 'resources/replays_rx' ap_path = Path.cwd() / 'resources/replays_ap' web = Router(f'osu.{glob.config.domain}') async def auth(name: str, md5: str, req: Request) -> bool: if not (player := await glob.players.find_login(name, md5)): log(f'{name} failed authentication', Ansi.LRED) return False req.extras['player'] = player return True if glob.config.debug: @web.after_request() async def logRequest(resp: Request) -> Request:
from pathlib import Path from xevel import Router, Request from objects import glob ava_path = Path.cwd() / 'resources/avatars' avatars = Router(f'a.{glob.config.domain}') @avatars.route("/") async def default_avatar(req: Request) -> bytes: file = ava_path / 'default.png' req.resp_headers['Content-Type'] = 'image/png' return file.read_bytes() @avatars.route("/<uid>") async def avatar(req: Request, uid: str) -> bytes: user = ava_path / f'{uid}' if user.exists(): req.resp_headers['Content-Type'] = 'image/png' return user.read_bytes() else: default = ava_path / 'default.png' req.resp_headers['Content-Type'] = 'image/png' return default.read_bytes()
from constants.countries import country_codes from constants.types import osuTypes, teamTypes from constants.privs import Privileges, ClientPrivileges from constants.mods import Mods from constants.modes import lbModes from constants import commands from constants import regexes from packets import writer, reader from packets.writer import Packets if glob.config.server_migration: import bcrypt bancho = Router({ # handler for webserver :D f'c.{glob.config.domain}', f'c4.{glob.config.domain}', f'ce.{glob.config.domain}' }) rdr = database.Reader('ext/geoloc.mmdb') def packet(pck: Packets, allow_res: bool = False): def wrapper(_cb): glob.packets |= {pck: _cb} if allow_res: glob.packets_restricted |= {pck: _cb} return wrapper @packet(Packets.OSU_REQUEST_STATUS_UPDATE, allow_res=True)
from xevel import Router, Request from pathlib import Path from typing import Union from objects import glob assets = Router(f'assets.{glob.config.domain}') custom = [] def init_customs(): for ach in glob.achievements: if ach.custom: custom.append(ach.image) # client likes @2x custom.append(f'{ach.image}@2x') @assets.route("/medals/client/<medal>") async def ingameAchievements(request: Request, medal: str) -> Union[tuple, bytes]: name = medal.split('.')[0] if name not in custom: request.resp_headers[ 'Location'] = f'https://assets.ppy.sh/medals/client/{medal}' # redirect regular achievements return (301, b'') else: request.resp_headers['Content-Type'] = 'image/png' return ( Path.cwd() /
from objects.match import slotStatus from objects.match import Teams from objects.player import Player from packets import reader from packets import writer from packets.writer import Packets from utils.logging import warning, info, debug if glob.config.server_migration: import bcrypt bancho = Router( { # handler for webserver :D f"c.{glob.config.domain}", f"c4.{glob.config.domain}", f"ce.{glob.config.domain}", }, ) rdr = database.Reader("ext/geoloc.mmdb") def packet(pck: Packets, allow_res: bool = False): def wrapper(_cb): glob.packets |= {pck: _cb} if allow_res: glob.packets_restricted |= {pck: _cb} return wrapper
from cmyui.osu.oppai_ng import OppaiWrapper from xevel import Request from xevel import Router from constants.modes import lbModes from constants.modes import osuModes from constants.mods import Mods from constants.privs import Privileges from objects import glob from objects.beatmap import Beatmap from packets import writer from utils.logging import error, info api = Router(f"api.{glob.config.domain}") if glob.config.debug: @api.after_request() async def logRequest(resp: Request) -> Request: if resp.code >= 400: log_func = error else: log_func = info log_func( f"[{resp.type}] {resp.code} {resp.url} | Time Elapsed: {resp.elapsed}", ) return resp
from pathlib import Path from datetime import datetime from typing import Union from objects import glob from objects.beatmap import Beatmap from constants.mods import Mods from constants.modes import osuModes, lbModes from constants.privs import Privileges from packets import writer import hashlib import struct api = Router(f'api.{glob.config.domain}') if glob.config.debug: @api.after_request() async def logRequest(resp: Request) -> Request: if resp.code >= 400: colourret = Ansi.LRED else: colourret = Ansi.LCYAN log( f'[{resp.type}] {resp.code} {resp.url} | Time Elapsed: {resp.elapsed}', colourret) return resp
from constants.statuses import mapStatuses from constants.statuses import scoreStatuses from objects import glob from objects.beatmap import Beatmap from objects.leaderboard import Leaderboard from objects.score import Score from packets import writer from utils.logging import warning, error, info ss_path = Path.cwd() / "resources/screenshots" vn_path = Path.cwd() / "resources/replays" rx_path = Path.cwd() / "resources/replays_rx" ap_path = Path.cwd() / "resources/replays_ap" web = Router(f"osu.{glob.config.domain}") async def auth(_name: str, md5: str, req: Request) -> bool: name = unquote(_name) if not (player := await glob.players.find_login(name, md5)): warning(f"{name} failed authentication") return False req.extras["player"] = player return True if glob.config.debug:
from pathlib import Path from xevel import Request from xevel import Router from objects import glob ava_path = Path.cwd() / "resources/avatars" avatars = Router(f"a.{glob.config.domain}") @avatars.route("/") async def default_avatar(req: Request) -> bytes: file = ava_path / "default.png" req.resp_headers["Content-Type"] = "image/png" return file.read_bytes() @avatars.route("/<uid>") async def avatar(req: Request, uid: str) -> bytes: user = ava_path / f"{uid}" if user.exists(): req.resp_headers["Content-Type"] = "image/png" return user.read_bytes() else: default = ava_path / "default.png" req.resp_headers["Content-Type"] = "image/png" return default.read_bytes()