support custom location for database persistent statefile (defaults to "capport.state" in cwd)
This commit is contained in:
parent
8eedb6b367
commit
9e31c8c673
@ -11,3 +11,4 @@ server-names:
|
||||
- ...
|
||||
api-port: 8000
|
||||
controller-port: 5000
|
||||
database-file: capport.state
|
||||
|
@ -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
|
||||
|
@ -23,6 +23,7 @@ class Config:
|
||||
session_timeout: int # in seconds
|
||||
api_port: int
|
||||
controller_port: int
|
||||
database_file: str # empty str: disable database
|
||||
debug: bool
|
||||
|
||||
@staticmethod
|
||||
@ -58,6 +59,7 @@ class Config:
|
||||
session_timeout=data.pop('session-timeout', 3600),
|
||||
api_port=data.pop('api-port', 8000),
|
||||
controller_port=data.pop('controller-port', 5000),
|
||||
database_file=str(data.pop('database-file', 'capport.state')),
|
||||
debug=data.pop('debug', False)
|
||||
)
|
||||
if data:
|
||||
|
@ -139,7 +139,7 @@ class NotReadyYet(Exception):
|
||||
|
||||
|
||||
class Database:
|
||||
def __init__(self, state_filename: typing.Optional[str] = None):
|
||||
def __init__(self, state_filename: str = ""):
|
||||
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