From f5f1f9b91f8bb40895f397961ed19300848a306c Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Thu, 7 Oct 2021 09:43:22 -0700 Subject: [PATCH] fix ACL bug, fix server listing --- config.py | 2 +- data_gateway_config.py | 2 ++ hblink.py | 22 ++++++++++++------ web/app.py | 51 ++++++++++++++++++++++-------------------- 4 files changed, 45 insertions(+), 32 deletions(-) diff --git a/config.py b/config.py index 040821f..6e62b00 100755 --- a/config.py +++ b/config.py @@ -68,7 +68,6 @@ def acl_build(_acl, _max): return(True, set((const.ID_MIN, _max))) acl = [] #set() - print(type(_acl)) if type(_acl) == tuple: _acl = ''.join(_acl) sections = _acl.split(':') @@ -319,6 +318,7 @@ def build_config(_config_file): 'ENABLED': config.getboolean(section, 'ENABLED'), 'EXTERNAL_PROXY_SCRIPT': config.getboolean(section, 'EXTERNAL_PROXY_SCRIPT'), 'STATIC_APRS_POSITION_ENABLED': config.getboolean(section, 'STATIC_APRS_POSITION_ENABLED'), + 'USE_USER_MAN': config.getboolean(section, 'USE_USER_MAN'), 'REPEAT': config.getboolean(section, 'REPEAT'), 'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE'), 'utf-8'), 'EXTERNAL_PORT': config.getint(section, 'EXTERNAL_PORT'), diff --git a/data_gateway_config.py b/data_gateway_config.py index 6a8e6fb..730a439 100644 --- a/data_gateway_config.py +++ b/data_gateway_config.py @@ -68,6 +68,8 @@ def acl_build(_acl, _max): return(True, set((const.ID_MIN, _max))) acl = [] #set() + if type(_acl) == tuple: + _acl = ''.join(_acl) sections = _acl.split(':') if sections[0] == 'PERMIT': diff --git a/hblink.py b/hblink.py index bb46dfb..32da2b0 100755 --- a/hblink.py +++ b/hblink.py @@ -621,6 +621,9 @@ class HBSYSTEM(DatagramProtocol): elif _command == RPTL: # RPTLogin -- a repeater wants to login _peer_id = _data[4:8] + print() + print((self._config['REG_ACL'])) + print() # Check to see if we've reached the maximum number of allowed peers if len(self._peers) < self._config['MAX_PEERS']: # Check for valid Radio ID @@ -635,15 +638,20 @@ class HBSYSTEM(DatagramProtocol): else: user_auth = False elif self._config['USE_USER_MAN'] == False: -## print('False') -#### print(self._config['REG_ACL']) -## print(self._CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED']) + print('False') b_acl = self._config['REG_ACL'] if self._CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True: - b_acl = acl_build(self._config['REG_ACL'], 4294967295) - print(b_acl) - if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, b_acl):#acl_check(_peer_id, b_acl): - user_auth = True + # If UMS is False, and Rmote Confir True + if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']): + user_auth = True + print(self._CONFIG['GLOBAL']['REG_ACL']) + else: + user_auth = False + #If UMS and Remot Config False + elif self._CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == False: + user_auth = False + if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, b_acl):#acl_check(_peer_id, b_acl): + user_auth = True if user_auth == True: # Build the configuration data strcuture for the peer self._peers.update({_peer_id: { diff --git a/web/app.py b/web/app.py index 4678961..84f0313 100644 --- a/web/app.py +++ b/web/app.py @@ -919,29 +919,32 @@ def hbnet_web_service(): script_links = ast.literal_eval(script_l.field_2) svr_content = '' for i in sl: - try: - if time.time() - ping_list[i.name] < 20: - svr_status = '''
- Online -
''' - elif time.time() - ping_list[i.name] <= 300: + if i.ip == '': + break + elif i.ip != '': + try: + if time.time() - ping_list[i.name] < 20: + svr_status = '''
+ Online +
''' + elif time.time() - ping_list[i.name] <= 300: + svr_status = '''
+ Unknown
(No pings, less than 5 min.)
+
''' + elif time.time() - ping_list[i.name] > 300: + svr_status = '''
+ Offline +
''' + else: + svr_status = '''
+ Unknown Condition +
''' + print(ping_list) + print(time.time()) + except: svr_status = '''
- Unknown
(No pings, less than 5 min.)
-
''' - elif time.time() - ping_list[i.name] > 300: - svr_status = '''
- Offline -
''' - else: - svr_status = '''
- Unknown Condition -
''' - print(ping_list) - print(time.time()) - except: - svr_status = '''
- Unknown -
''' + Unknown + ''' svr_content = svr_content + '''
@@ -3731,7 +3734,7 @@ TG #: ''' + str(tg_d.tg) + '''   - Host (IP/DNS, for listing on passphrase page): + Host (IP/DNS, for listing on passphrase page, blank to not list):   @@ -3938,7 +3941,7 @@ TG #: ''' + str(tg_d.tg) + '''   - Host (IP/DNS): + Host (IP/DNS, blank to not list):