forked from lugvitc/pwncore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,38 @@ | ||
from __future__ import annotations | ||
|
||
import typing as t | ||
|
||
__all__ = ( | ||
"Config", | ||
"BaseConfig", | ||
) | ||
|
||
|
||
class Config(t.Protocol): | ||
development: bool | ||
flag: str | ||
max_containers_per_team: int | ||
messages: dict | ||
|
||
|
||
class BaseConfig(Config): | ||
__slots__ = ("development",) | ||
|
||
flag = "C0D" | ||
max_containers_per_team = 3 | ||
messages = { | ||
"db_error": "An error occured, please try again.", | ||
|
||
"port_limit_reached": "Server ran out of ports 💀", | ||
|
||
"ctf_not_found": "CTF does not exist.", | ||
|
||
"container_start": "Container started.", | ||
"container_stop": "Container stopped.", | ||
"containers_team_stop": "All team containers stopped.", | ||
"container_not_found": "You have no running containers for this CTF.", | ||
"container_already_running": "Your team already has a running container for this CTF.", | ||
"container_limit_reached": "Your team already has reached the maximum number of containers limit, please stop other unused containers." | ||
} | ||
|
||
def __init__(self, development: bool) -> None: | ||
self.development = development | ||
|
||
DEV_CONFIG: t.Final[BaseConfig] = BaseConfig(True) | ||
|
||
config = DEV_CONFIG | ||
from dataclasses import dataclass | ||
|
||
""" | ||
Sample messages: | ||
"db_error": "An error occurred, please try again.", | ||
"port_limit_reached": "Server ran out of ports 💀", | ||
"ctf_not_found": "CTF does not exist.", | ||
"container_start": "Container started.", | ||
"container_stop": "Container stopped.", | ||
"containers_team_stop": "All team containers stopped.", | ||
"container_not_found": "You have no running containers for this CTF.", | ||
"container_already_running": "Your team already has a running container for this CTF.", | ||
"container_limit_reached": "Your team already has reached the maximum number of containers limit, please stop other unused containers." | ||
""" | ||
|
||
msg_codes = { | ||
"db_error": 0, | ||
"port_limit_reached": 1, | ||
"ctf_not_found": 2, | ||
"container_start": 3, | ||
"container_stop": 4, | ||
"containers_team_stop": 5, | ||
"container_not_found": 6, | ||
"container_already_running": 7, | ||
"container_limit_reached": 8 | ||
} | ||
|
||
|
||
@dataclass | ||
class Config: | ||
development: bool | ||
msg_codes: dict | ||
db_url: str = "sqlite://:memory:" | ||
flag: str = "C0D" | ||
max_containers_per_team: int = 3 | ||
|
||
|
||
config = Config(development=True, msg_codes=msg_codes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters