mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
UI: add missing config fields if the don't exist
If we've added in a new release new config fields, old clients may not have them, so we add them. We need a better way of handling upgrades.
This commit is contained in:
parent
c444d5f8a1
commit
2cd18f3bcb
1 changed files with 13 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
from queue import Queue
|
||||
from datetime import datetime
|
||||
import json
|
||||
|
||||
class Nodes():
|
||||
__instance = None
|
||||
|
@ -42,7 +43,7 @@ class Nodes():
|
|||
|
||||
def add_data(self, addr, client_config):
|
||||
if client_config != None:
|
||||
self._nodes[addr]['data'] = client_config
|
||||
self._nodes[addr]['data'] = self.get_client_config(client_config)
|
||||
|
||||
def delete_all(self):
|
||||
self.send_notifications(None)
|
||||
|
@ -60,6 +61,17 @@ class Nodes():
|
|||
def get(self):
|
||||
return self._nodes
|
||||
|
||||
def get_client_config(self, client_config):
|
||||
try:
|
||||
node_config = json.loads(client_config.config)
|
||||
if 'LogLevel' not in node_config:
|
||||
node_config['LogLevel'] = 1
|
||||
client_config.config = json.dumps(node_config)
|
||||
except Exception as e:
|
||||
print(self.LOG_TAG, "exception parsing client config", e)
|
||||
|
||||
return client_config
|
||||
|
||||
def get_addr(self, peer):
|
||||
peer = peer.split(":")
|
||||
return peer[0], peer[1]
|
||||
|
|
Loading…
Add table
Reference in a new issue