Add more config file validation
This commit is contained in:
parent
a2947a574c
commit
3a608a1636
1 changed files with 15 additions and 0 deletions
|
@ -26,6 +26,15 @@ class Server():
|
|||
self.sslctx = None
|
||||
|
||||
if config['listen'].get('tls', 'no') == 'yes':
|
||||
if not config.has_section('tls'):
|
||||
raise ConfigSectionException('tls')
|
||||
|
||||
if not config.has_option('tls', 'cert'):
|
||||
raise ConfigValueException('tls', 'cert')
|
||||
|
||||
if not config.has_option('tls', 'key'):
|
||||
raise ConfigValueException('tls', 'key')
|
||||
|
||||
self.sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
||||
self.sslctx.load_cert_chain(config['tls']['cert'],
|
||||
config['tls']['key'])
|
||||
|
@ -33,6 +42,12 @@ class Server():
|
|||
self._init_newsgroups()
|
||||
|
||||
def connect_to_db(self):
|
||||
if not self.config.has_section('database'):
|
||||
raise ConfigSectionException('database')
|
||||
|
||||
if not self.config.has_option('database', 'path'):
|
||||
raise ConfigValueException('database', 'path')
|
||||
|
||||
return Database.connect(self.config['database']['path'])
|
||||
|
||||
def _init_newsgroups(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue