2023-02-17 07:09:26 +00:00
|
|
|
from core.config import CoreConfig
|
|
|
|
|
2023-03-09 16:38:58 +00:00
|
|
|
|
|
|
|
class PokkenServerConfig:
|
2023-02-17 07:09:26 +00:00
|
|
|
def __init__(self, parent_config: "PokkenConfig"):
|
|
|
|
self.__config = parent_config
|
2023-03-09 16:38:58 +00:00
|
|
|
|
2023-03-05 02:27:52 +00:00
|
|
|
@property
|
|
|
|
def hostname(self) -> str:
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "pokken", "server", "hostname", default="localhost"
|
|
|
|
)
|
|
|
|
|
2023-02-17 07:09:26 +00:00
|
|
|
@property
|
|
|
|
def enable(self) -> bool:
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "pokken", "server", "enable", default=True
|
|
|
|
)
|
2023-02-17 07:09:26 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def loglevel(self) -> int:
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.str_to_loglevel(
|
|
|
|
CoreConfig.get_config_field(
|
|
|
|
self.__config, "pokken", "server", "loglevel", default="info"
|
|
|
|
)
|
|
|
|
)
|
2023-02-17 07:09:26 +00:00
|
|
|
|
|
|
|
@property
|
2023-06-25 05:09:23 +00:00
|
|
|
def auto_register(self) -> bool:
|
|
|
|
"""
|
|
|
|
Automatically register users in `aime_user` on first carding in with pokken
|
|
|
|
if they don't exist already. Set to false to display an error instead.
|
|
|
|
"""
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
2023-06-25 05:09:23 +00:00
|
|
|
self.__config, "pokken", "server", "auto_register", default=True
|
2023-03-09 16:38:58 +00:00
|
|
|
)
|
2023-02-17 07:09:26 +00:00
|
|
|
|
2023-03-05 02:27:52 +00:00
|
|
|
@property
|
2023-06-25 05:09:23 +00:00
|
|
|
def enable_matching(self) -> bool:
|
|
|
|
"""
|
|
|
|
If global matching should happen
|
|
|
|
"""
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
2023-06-25 05:09:23 +00:00
|
|
|
self.__config, "pokken", "server", "enable_matching", default=False
|
2023-03-09 16:38:58 +00:00
|
|
|
)
|
2023-06-25 05:09:23 +00:00
|
|
|
|
2023-03-05 02:27:52 +00:00
|
|
|
@property
|
2023-06-25 05:09:23 +00:00
|
|
|
def stun_server_host(self) -> str:
|
|
|
|
"""
|
|
|
|
Hostname of the EXTERNAL stun server the game should connect to. This is not handled by artemis.
|
|
|
|
"""
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
2023-06-25 05:09:23 +00:00
|
|
|
self.__config, "pokken", "server", "stun_server_host", default="stunserver.stunprotocol.org"
|
2023-03-09 16:38:58 +00:00
|
|
|
)
|
2023-03-05 02:27:52 +00:00
|
|
|
|
|
|
|
@property
|
2023-06-25 05:09:23 +00:00
|
|
|
def stun_server_port(self) -> int:
|
|
|
|
"""
|
|
|
|
Port of the EXTERNAL stun server the game should connect to. This is not handled by artemis.
|
|
|
|
"""
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
2023-06-25 05:09:23 +00:00
|
|
|
self.__config, "pokken", "server", "stun_server_port", default=3478
|
2023-03-09 16:38:58 +00:00
|
|
|
)
|
|
|
|
|
2023-06-25 05:09:23 +00:00
|
|
|
class PokkenPortsConfig:
|
|
|
|
def __init__(self, parent_config: "PokkenConfig"):
|
|
|
|
self.__config = parent_config
|
|
|
|
|
2023-04-10 08:42:40 +00:00
|
|
|
@property
|
2023-06-25 05:09:23 +00:00
|
|
|
def game(self) -> int:
|
2023-04-10 08:42:40 +00:00
|
|
|
return CoreConfig.get_config_field(
|
2023-06-25 05:09:23 +00:00
|
|
|
self.__config, "pokken", "ports", "game", default=9000
|
2023-04-10 08:42:40 +00:00
|
|
|
)
|
|
|
|
|
2023-06-25 05:09:23 +00:00
|
|
|
@property
|
|
|
|
def admission(self) -> int:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "pokken", "ports", "admission", default=9001
|
|
|
|
)
|
|
|
|
|
2023-04-24 01:04:52 +00:00
|
|
|
|
2023-02-17 07:09:26 +00:00
|
|
|
class PokkenConfig(dict):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
self.server = PokkenServerConfig(self)
|
2023-06-25 05:09:23 +00:00
|
|
|
self.ports = PokkenPortsConfig(self)
|