feat(client-verification): add client verification (#104)
New configurations: - `CHECK_CLIENT_VERSION` enables the check (default=True) - `CLIENT_VERSION_URLS` contains a chain of valid client hashes. [osu!](https://osu.ppy.sh/home/download) and [osu! GU](https://github.com/GooGuTeam/osu/releases) are valid by default. View [g0v0-client-versions](https://github.com/GooGuTeam/g0v0-client-versions) to learn how to support your own client. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
27
app/models/version.py
Normal file
27
app/models/version.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from typing import NamedTuple, TypedDict
|
||||
|
||||
|
||||
class VersionInfo(TypedDict):
|
||||
version: str
|
||||
release_date: str
|
||||
hashes: dict[str, str]
|
||||
|
||||
|
||||
class VersionList(TypedDict):
|
||||
name: str
|
||||
versions: list[VersionInfo]
|
||||
|
||||
|
||||
class VersionCheckResult(NamedTuple):
|
||||
is_valid: bool
|
||||
client_name: str = ""
|
||||
version: str = ""
|
||||
os: str = ""
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
return self.is_valid
|
||||
|
||||
def __str__(self) -> str:
|
||||
if self.is_valid:
|
||||
return f"{self.client_name} {self.version} ({self.os})"
|
||||
return "Invalid Client Version"
|
||||
Reference in New Issue
Block a user