support custom location for database persistent statefile (defaults to "capport.state" in cwd)
This commit is contained in:
parent
4f08ff796b
commit
c4a75dd7a7
@ -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
|
||||
|
@ -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)
|
||||
)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user