2023-05-26 19:45:20 +02:00
|
|
|
from core.config import CoreConfig
|
|
|
|
|
|
|
|
|
|
|
|
class SaoServerConfig:
|
|
|
|
def __init__(self, parent_config: "SaoConfig"):
|
|
|
|
self.__config = parent_config
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enable(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "sao", "server", "enable", default=True
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def loglevel(self) -> int:
|
|
|
|
return CoreConfig.str_to_loglevel(
|
|
|
|
CoreConfig.get_config_field(
|
|
|
|
self.__config, "sao", "server", "loglevel", default="info"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def auto_register(self) -> bool:
|
|
|
|
"""
|
|
|
|
Automatically register users in `aime_user` on first carding in with sao
|
|
|
|
if they don't exist already. Set to false to display an error instead.
|
|
|
|
"""
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "sao", "server", "auto_register", default=True
|
|
|
|
)
|
|
|
|
|
2023-11-09 17:51:50 +01:00
|
|
|
class SaoCryptConfig:
|
|
|
|
def __init__(self, parent_config: "SaoConfig"):
|
|
|
|
self.__config = parent_config
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enable(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "sao", "crypt", "enable", default=False
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def key(self) -> str:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "sao", "crypt", "key", default=""
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def iv(self) -> str:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "sao", "crypt", "iv", default=""
|
|
|
|
)
|
|
|
|
|
2023-05-26 19:45:20 +02:00
|
|
|
|
|
|
|
class SaoConfig(dict):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
self.server = SaoServerConfig(self)
|
2023-11-09 17:51:50 +01:00
|
|
|
self.crypt = SaoCryptConfig(self)
|