diff --git a/src/capport/comm/hub.py b/src/capport/comm/hub.py index 8558771..1420e10 100644 --- a/src/capport/comm/hub.py +++ b/src/capport/comm/hub.py @@ -299,11 +299,11 @@ class Hub: self._hostname = socket.getfqdn() self._app = app self._is_controller = is_controller - state_filename: typing.Optional[str] + state_filename: str if is_controller: - state_filename = 'capport.state' + state_filename = config.database_file else: - state_filename = None + state_filename = '' self.database = capport.database.Database(state_filename=state_filename) self._anon_context = ssl.SSLContext() # python ssl doesn't support setting tls1.3 ciphers yet, so make sure we stay on 1.2 for now to enable anon diff --git a/src/capport/config.py b/src/capport/config.py index 8311382..47817b0 100644 --- a/src/capport/config.py +++ b/src/capport/config.py @@ -19,6 +19,7 @@ class Config: cookie_secret: str venue_info_url: typing.Optional[str] session_timeout: int # in seconds + database_file: str # empty str: disable database debug: bool @staticmethod @@ -45,9 +46,10 @@ class Config: return Config( controllers=controllers, server_names=data.get('server-names', []), - comm_secret=str(data.get('comm-secret', None) or data['secret']), + comm_secret=str(data['comm-secret']), cookie_secret=str(data['cookie-secret']), venue_info_url=str(data.get('venue-info-url')), session_timeout=data.get('session-timeout', 3600), + database_file=str(data['database-file']) if 'database-file' in data else 'capport.state', debug=data.get('debug', False) ) diff --git a/src/capport/database.py b/src/capport/database.py index 3907dbd..17dbd24 100644 --- a/src/capport/database.py +++ b/src/capport/database.py @@ -139,7 +139,7 @@ class NotReadyYet(Exception): class Database: - def __init__(self, state_filename: typing.Optional[str] = None): + def __init__(self, state_filename: str = None): self._macs: dict[cptypes.MacAddress, MacEntry] = {} self._state_filename = state_filename self._changed_since_last_cleanup = False