Implement Config.section() to fetch, validate config sections

This commit is contained in:
XANTRONIX Development 2024-12-04 12:03:54 -05:00
parent 7653ebdd29
commit 1e915b5007
2 changed files with 7 additions and 1 deletions

View file

@ -61,6 +61,12 @@ class Config(configparser.ConfigParser):
return config
def section(self, section: str):
if not self.has_section(section):
raise ConfigSectionException(section)
return self[section]
def get(self, section: str, option: str, *args, **kwargs):
if not self.has_section(section):
raise ConfigSectionException(section)

View file

@ -22,7 +22,7 @@ class Server():
self.newsgroups = dict()
self.sslctx = None
if config['listen'].get('tls', 'no') == 'yes':
if config.section('listen').get('tls', 'no') == 'yes':
self.sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
self.sslctx.load_cert_chain(config.get('tls', 'cert'),
config.get('tls', 'key'))