fix ACL bug, fix server listing

This commit is contained in:
KF7EEL 2021-10-07 09:43:22 -07:00
parent 69b8570ee2
commit f5f1f9b91f
4 changed files with 45 additions and 32 deletions

View File

@ -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'),

View File

@ -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':

View File

@ -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: {

View File

@ -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 = '''<div class="alert alert-success">
<strong>Online</strong>
</div> '''
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 = '''<div class="alert alert-success">
<strong>Online</strong>
</div> '''
elif time.time() - ping_list[i.name] <= 300:
svr_status = '''<div class="alert alert-warning">
<strong>Unknown <br /> (No pings, less than 5 min.)</strong>
</div> '''
elif time.time() - ping_list[i.name] > 300:
svr_status = '''<div class="alert alert-danger">
<strong>Offline</strong>
</div> '''
else:
svr_status = '''<div class="alert alert-warning">
<strong>Unknown Condition</strong>
</div> '''
print(ping_list)
print(time.time())
except:
svr_status = '''<div class="alert alert-warning">
<strong>Unknown <br /> (No pings, less than 5 min.)</strong>
</div> '''
elif time.time() - ping_list[i.name] > 300:
svr_status = '''<div class="alert alert-danger">
<strong>Offline</strong>
</div> '''
else:
svr_status = '''<div class="alert alert-warning">
<strong>Unknown Condition</strong>
</div> '''
print(ping_list)
print(time.time())
except:
svr_status = '''<div class="alert alert-warning">
<strong>Unknown</strong>
</div> '''
<strong>Unknown</strong>
</div> '''
svr_content = svr_content + '''
<div class="card">
@ -3731,7 +3734,7 @@ TG #: <strong> ''' + str(tg_d.tg) + '''</strong>
<td style="width: 78.7895%;">&nbsp;<input name="dash_url" type="text" value="''' + str(s.dash_url) + '''"/></td>
</tr>
<tr>
<td style="width: 16.0381%;"><strong>&nbsp;Host (IP/DNS, for listing on passphrase page):</strong></td>
<td style="width: 16.0381%;"><strong>&nbsp;Host (IP/DNS, for listing on passphrase page, blank to not list):</strong></td>
<td style="width: 78.7895%;">&nbsp;<input name="server_ip" type="text" value="''' + str(s.ip) + '''"/></td>
</tr>
@ -3938,7 +3941,7 @@ TG #: <strong> ''' + str(tg_d.tg) + '''</strong>
<td style="width: 70%;">&nbsp;<input name="dash_url" type="text" /></td>
</tr>
<tr>
<td style="width: 16.0381%;"><strong>&nbsp;Host (IP/DNS):</strong></td>
<td style="width: 16.0381%;"><strong>&nbsp;Host (IP/DNS, blank to not list):</strong></td>
<td style="width: 78.7895%;">&nbsp;<input name="server_ip" type="text" /></td>
</tr>