Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5.0.0 - Overall project restructuring & refactoring #205

Closed
wants to merge 75 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
4c95a72
splitting objects into (objects, usecases, repos) (1/?)
cmyui Mar 24, 2022
a37216e
add missing import
cmyui Mar 24, 2022
2559e78
revert casing change of RankedStatus enum
cmyui Mar 24, 2022
fc2a230
Merge branch 'master' into code-cleanup-refactor
cmyui Apr 15, 2022
b12d83a
ignore incorrect typeerrors
cmyui Apr 15, 2022
f02d6a1
support mino mirror, refactor mail, comments, favoruites, direct into…
cmyui Apr 16, 2022
11c9b63
move more score submission logic into usecases
cmyui Apr 16, 2022
ba9e156
fix missing usage of players usecases in commands
cmyui Apr 16, 2022
122155a
continue to refactor server into (models, repositories, usecases)
cmyui Apr 16, 2022
2f53457
remove Beatmap._parse_from_osuapi_resp
cmyui Apr 16, 2022
9944e2c
re-add directory imports to app/__init__.py
cmyui Apr 16, 2022
7aa2cbf
move geolocation to objects
cmyui Apr 16, 2022
4e86ebb
add usecase/repository entry for updating beatmap(set) status
cmyui Apr 16, 2022
3a91f22
more work refactoring logic & data fetching from models
cmyui Apr 17, 2022
f222511
more refactoring into apps & usecases, code cleaup
cmyui Apr 18, 2022
b613b52
james unmindblocked me
cmyui Apr 18, 2022
7ffc9ea
continued code cleanup and refactoring
cmyui Apr 18, 2022
88b3bc3
attach missing message in SendPrivateMessage packet handler
cmyui Apr 18, 2022
6291357
fix update_matchpoints() call
cmyui Apr 18, 2022
aeec0ad
fix score submission charts
cmyui Apr 22, 2022
8fba7b0
change import style of usecases & repositories
cmyui Apr 22, 2022
0c738c3
re-enabling init of server repository caches at startup
cmyui Apr 23, 2022
66ff238
more refactoring into usecases/repositories, add validation & responses
cmyui Apr 24, 2022
05b2e2e
Merge branch 'master' into code-cleanup-refactor
cmyui Apr 24, 2022
f531359
continued refactoring (more progress & fixes)
cmyui Apr 27, 2022
19576fe
small changes to `/web/osu-getbeatmapinfo.php`
cmyui Apr 27, 2022
013d43f
move tests/ into app/
cmyui Apr 27, 2022
19662ab
refactor score submission endpoint
cmyui Apr 28, 2022
1a7b040
misc cleanup
cmyui Apr 28, 2022
cab9167
Merge branch 'master' into code-cleanup-refactor
cmyui Apr 28, 2022
700d599
add warnings to deprecated packets
cmyui Apr 29, 2022
f8cc856
refactor menus
cmyui Apr 29, 2022
a5863d4
misc minor cleanup
cmyui Apr 29, 2022
6617c32
create simple base for testing usecases & validation
cmyui Apr 29, 2022
bcb3986
use `(1 << 31) - 1` in place of `2_147_483_647`
cmyui May 6, 2022
817e3b3
remove unnecessary defaults from settings (py layer)
cmyui May 6, 2022
8c0aec7
mino HQ audio preview support (disabled for now)
cmyui May 6, 2022
bf49f44
Merge branch 'master' into code-cleanup-refactor
cmyui May 6, 2022
447ce53
Merge branch 'master' into code-cleanup-refactor
cmyui Jun 10, 2022
ca0ee29
simplify logging systems
cmyui Jul 1, 2022
3c73b78
refactor sql & redis connection config & health checks
cmyui Jul 3, 2022
c02ad12
remove requirements & docs for ssl certificate generation
cmyui Jul 4, 2022
655a32a
genericize & add instructions to nginx.conf default config
cmyui Jul 4, 2022
ca0d51a
update version (v5.0.0)
cmyui Jul 4, 2022
42b91f0
Merge branch 'master' into code-cleanup-refactor
cmyui Jul 4, 2022
544ace7
update pre-commit hooks
cmyui Jul 4, 2022
e43f511
auto accept apt install prompt in setup guide
cmyui Jul 4, 2022
1f4a2fb
fix output from ./main.py -V
cmyui Jul 4, 2022
01da143
reduce usage of typing.TYPE_CHECKING
cmyui Jul 4, 2022
0e71215
split Player class into Account & Player
cmyui Jul 5, 2022
119e5a7
refactor player repository fetch methods
cmyui Jul 5, 2022
1030729
work around disagreement with pyright & reorder-python-imports
cmyui Jul 5, 2022
dc660e8
use 'vanilla' mode in `GET /scores/{score_id}/replay` response
cmyui Jul 5, 2022
e5a8707
simplifications to GameMode
cmyui Jul 5, 2022
eb8597c
Merge branch 'master' into code-cleanup-refactor
cmyui Jul 5, 2022
32fbda3
fix usage of player repository fetch() calls
cmyui Jul 5, 2022
0141740
fix info in `GET /players/{player_id}/{scope}`
cmyui Jul 5, 2022
0dc1187
Merge branch 'master' into code-cleanup-refactor
cmyui Jul 5, 2022
e3b4292
use cache more frequently in player repository
cmyui Jul 5, 2022
7727aa0
player model/repository cleanup
cmyui Jul 5, 2022
bc7e9da
update cached object in player repo set_donator_end()
cmyui Jul 5, 2022
fadad58
refactor repositories into more consistent scheme
cmyui Jul 5, 2022
dbadffa
re-enable name check in !clan create
cmyui Jul 5, 2022
2d410a4
update cached object in beatmap repo update_playcounts()
cmyui Jul 5, 2022
3e7bb70
consistent cache interface in players repo
cmyui Jul 5, 2022
0b47236
remove stealth mode
cmyui Jul 5, 2022
75cd619
misc player usecases & repository cleanup
cmyui Jul 5, 2022
0bf6c34
continued refactoring into models/repositories/usecases
cmyui Jul 6, 2022
0082182
split fetch_rating usecase into repo
cmyui Jul 6, 2022
eef9cc3
fix beatmap caching from beatmap_sets repo
cmyui Jul 11, 2022
c943a1a
Merge branch 'master' into code-cleanup-refactor
cmyui Jul 11, 2022
a99006b
improve beatmap set replace() logic
cmyui Jul 11, 2022
ce64706
ensure osu!api key type is correct in getbeatmaps
cmyui Jul 11, 2022
f5c1cad
fix attributeerror bug in osu-rate.php
cmyui Jul 11, 2022
c022a16
fix incorrect name attribute usage in channels
cmyui Jul 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
# the environment your application is running in
# options include: local, staging, production
APP_ENV=local

# bancho.py supports both INET and UNIX sockets
# INET: provide an IP for SERVER_ADDR, and a port for SERVER_PORT
# UNIX: provide a filesystem path for SERVER_ADDR, and no SERVER_PORT
SERVER_ADDR=/tmp/bancho.sock
SERVER_PORT=

DB_DSN=mysql://username:password@localhost:3306/database
REDIS_DSN=redis://localhost
# database connections (mysql)
DB_HOST=localhost
DB_PORT=3306
DB_USER=username
DB_PASS=password
# NOTE: test db will have a suffix of "_test"
DB_NAME=bancho

REDIS_HOST=localhost
REDIS_PORT=6379

OSU_API_KEY=

DOMAIN=cmyui.xyz
MIRROR_URL=https://api.chimu.moe/v1
MIRROR_URL=https://catboy.best/api

COMMAND_PREFIX=!

Expand All @@ -22,17 +34,18 @@ MENU_ONCLICK_URL=https://akatsuki.pw
DATADOG_API_KEY=
DATADOG_APP_KEY=

DEBUG=False
# CRITICAL: 50 | ERROR: 40 | WARNING: 30 | INFO: 20 | DEBUG: 10
# https://docs.python.org/3/library/logging.html#levels
LOG_LEVEL=20

# redirect beatmaps, beatmapsets, and forum
# redirect beatmaps, beatmap sets, and forum
# pages of maps to the official osu! website
REDIRECT_OSU_URLS=True

PP_CACHED_ACCS=90,95,98,99,100
PP_CACHED_SCORES=800000,850000,900000,950000,1000000

DISALLOWED_NAMES=mrekk,vaxei,btmc,cookiezi
DISALLOWED_PASSWORDS=password,abc123

DISCORD_AUDIT_LOG_WEBHOOK=

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ext/GeoLite2-City.mmdb
.env
tools/migrate_v420/go.sum
tools/migrate_v420/scoreMigrator
.coverage
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ repos:
- id: check-ast
- id: check-builtin-literals
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
Expand Down
23 changes: 3 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ we aim to minimize our dependencies, but still rely on ones such as
- python (programming language)
- mysql (relational database)
- nginx (http(s) reverse proxy)
- certbot (ssl certificate tool)
- cmake and build-essential (build tools for c/c++)

as well as some others.
Expand All @@ -52,10 +51,10 @@ as well as some others.
sudo add-apt-repository ppa:deadsnakes

# install required programs for running bancho.py
sudo apt install python3.9-dev python3.9-distutils \
sudo apt install -y python3.9-dev python3.9-distutils \
cmake build-essential \
mysql-server redis-server \
nginx certbot
nginx

# install python's package manager, pip
# it's used to install python-specific dependencies
Expand All @@ -73,7 +72,7 @@ python3.9 -m pip install -r requirements.txt
you will need to create a database for bancho.py to store persistent data.

the server uses this database to store metadata & logs, such as user accounts
and stats, beatmaps and beatmapsets, chat channels, tourney mappools and more.
and stats, beatmaps and beatmap sets, chat channels, tourney mappools and more.

```sh
# login to mysql's shell with root - the default admin account
Expand Down Expand Up @@ -136,22 +135,6 @@ sql commands that can be run in sequence to create the base state we want.
mysql -u YOUR_DB_USER -p YOUR_DB_NAME < migrations/base.sql
```

## creating an ssl certificate (to allow https traffic)
```sh
# you'll need to change:
# - YOUR_EMAIL_ADDRESS
# - YOUR_DOMAIN

# generate an ssl certificate for your domain
sudo certbot certonly \
--manual \
--preferred-challenges=dns \
--email YOUR_EMAIL_ADDRESS \
--server https://acme-v02.api.letsencrypt.org/directory \
--agree-tos \
-d *.YOUR_DOMAIN
```

## configuring a reverse proxy (we'll use nginx)
bancho.py relies on a reverse proxy for tls (https) support, and for ease-of-use
in terms of configuration. nginx is an open-source and efficient web server we'll
Expand Down
7 changes: 6 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
from __future__ import annotations

from . import api
from . import bg_loops
from . import commands
from . import constants
from . import discord
from . import housekeeping
from . import logging
from . import menus
from . import objects
from . import packets
from . import repositories
from . import responses
from . import state
from . import usecases
from . import utils
from . import validation
40 changes: 40 additions & 0 deletions app/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

from ipaddress import IPv4Address
from ipaddress import IPv6Address
from typing import Literal
from typing import Union

AppEnvironments = Literal["local", "staging", "production"]

IPAddress = Union[IPv4Address, IPv6Address]

# some types used within the osu! client


OsuClientModes = Literal[
"Menu",
"Edit",
"Play",
"Exit",
"SelectEdit",
"SelectPlay",
"SelectDrawings",
"Rank",
"Update",
"Busy",
"Unknown",
"Lobby",
"MatchSetup",
"SelectMulti",
"RankingVs",
"OnlineSelection",
"OptionsOffsetWizard",
"RankingTagCoop",
"RankingTeam",
"BeatmapImport",
"PackageUpdater",
"Benchmark",
"Tourney",
"Charts",
]

OsuClientGameModes = Literal[
"Osu",
"Taiko",
"CatchTheBeat",
"OsuMania",
]
Loading