2023-02-17 07:02:21 +01:00
|
|
|
from core.config import CoreConfig
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
|
|
|
class CxbServerConfig:
|
2023-02-17 07:02:21 +01:00
|
|
|
def __init__(self, parent_config: "CxbConfig"):
|
|
|
|
self.__config = parent_config
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
@property
|
|
|
|
def enable(self) -> bool:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "cxb", "server", "enable", default=True
|
|
|
|
)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def loglevel(self) -> int:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.str_to_loglevel(
|
|
|
|
CoreConfig.get_config_field(
|
|
|
|
self.__config, "cxb", "server", "loglevel", default="info"
|
|
|
|
)
|
|
|
|
)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def hostname(self) -> str:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "cxb", "server", "hostname", default="localhost"
|
|
|
|
)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def ssl_enable(self) -> bool:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "cxb", "server", "ssl_enable", default=False
|
|
|
|
)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def port(self) -> int:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "cxb", "server", "port", default=8082
|
|
|
|
)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def port_secure(self) -> int:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "cxb", "server", "port_secure", default=443
|
|
|
|
)
|
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
@property
|
|
|
|
def ssl_cert(self) -> str:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "cxb", "server", "ssl_cert", default="cert/title.crt"
|
|
|
|
)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def ssl_key(self) -> str:
|
2023-03-09 17:38:58 +01:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "cxb", "server", "ssl_key", default="cert/title.key"
|
|
|
|
)
|
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
class CxbConfig(dict):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
self.server = CxbServerConfig(self)
|