clean up
This commit is contained in:
parent
bb4a8ff4d5
commit
17552507bb
18
hb_config.py
18
hb_config.py
@ -45,17 +45,17 @@ __email__ = 'n0mjs@me.com'
|
|||||||
def process_acls(_config):
|
def process_acls(_config):
|
||||||
# Global registration ACL
|
# Global registration ACL
|
||||||
_config['GLOBAL']['REG_ACL'] = acl_build(_config['GLOBAL']['REG_ACL'], const.PEER_MAX)
|
_config['GLOBAL']['REG_ACL'] = acl_build(_config['GLOBAL']['REG_ACL'], const.PEER_MAX)
|
||||||
|
|
||||||
# Global subscriber and TGID ACLs
|
# Global subscriber and TGID ACLs
|
||||||
for acl in ['SUB_ACL', 'TG1_ACL', 'TG2_ACL']:
|
for acl in ['SUB_ACL', 'TG1_ACL', 'TG2_ACL']:
|
||||||
_config['GLOBAL'][acl] = acl_build(_config['GLOBAL'][acl], const.ID_MAX)
|
_config['GLOBAL'][acl] = acl_build(_config['GLOBAL'][acl], const.ID_MAX)
|
||||||
|
|
||||||
# System level ACLs
|
# System level ACLs
|
||||||
for system in _config['SYSTEMS']:
|
for system in _config['SYSTEMS']:
|
||||||
# Registration ACLs (which make no sense for peer systems)
|
# Registration ACLs (which make no sense for peer systems)
|
||||||
if _config['SYSTEMS'][system]['MODE'] == 'MASTER':
|
if _config['SYSTEMS'][system]['MODE'] == 'MASTER':
|
||||||
_config['SYSTEMS'][system]['REG_ACL'] = acl_build(_config['SYSTEMS'][system]['REG_ACL'], const.PEER_MAX)
|
_config['SYSTEMS'][system]['REG_ACL'] = acl_build(_config['SYSTEMS'][system]['REG_ACL'], const.PEER_MAX)
|
||||||
|
|
||||||
# Subscriber and TGID ACLs (valid for all system types)
|
# Subscriber and TGID ACLs (valid for all system types)
|
||||||
for acl in ['SUB_ACL', 'TG1_ACL', 'TG2_ACL']:
|
for acl in ['SUB_ACL', 'TG1_ACL', 'TG2_ACL']:
|
||||||
_config['SYSTEMS'][system][acl] = acl_build(_config['SYSTEMS'][system][acl], const.ID_MAX)
|
_config['SYSTEMS'][system][acl] = acl_build(_config['SYSTEMS'][system][acl], const.ID_MAX)
|
||||||
@ -66,20 +66,20 @@ def process_acls(_config):
|
|||||||
def acl_build(_acl, _max):
|
def acl_build(_acl, _max):
|
||||||
if not _acl:
|
if not _acl:
|
||||||
return(True, set((const.ID_MIN, _max)))
|
return(True, set((const.ID_MIN, _max)))
|
||||||
|
|
||||||
acl = set()
|
acl = set()
|
||||||
sections = _acl.split(':')
|
sections = _acl.split(':')
|
||||||
|
|
||||||
if sections[0] == 'PERMIT':
|
if sections[0] == 'PERMIT':
|
||||||
action = True
|
action = True
|
||||||
else:
|
else:
|
||||||
action = False
|
action = False
|
||||||
|
|
||||||
for entry in sections[1].split(','):
|
for entry in sections[1].split(','):
|
||||||
if entry == 'ALL':
|
if entry == 'ALL':
|
||||||
acl.add((const.ID_MIN, _max))
|
acl.add((const.ID_MIN, _max))
|
||||||
break
|
break
|
||||||
|
|
||||||
elif '-' in entry:
|
elif '-' in entry:
|
||||||
start,end = entry.split('-')
|
start,end = entry.split('-')
|
||||||
start,end = int(start), int(end)
|
start,end = int(start), int(end)
|
||||||
@ -157,7 +157,6 @@ def build_config(_config_file):
|
|||||||
'MODE': config.get(section, 'MODE'),
|
'MODE': config.get(section, 'MODE'),
|
||||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||||
'LOOSE': config.getboolean(section, 'LOOSE'),
|
'LOOSE': config.getboolean(section, 'LOOSE'),
|
||||||
'EXPORT_AMBE': config.getboolean(section, 'EXPORT_AMBE'),
|
|
||||||
'SOCK_ADDR': (gethostbyname(config.get(section, 'IP')), config.getint(section, 'PORT')),
|
'SOCK_ADDR': (gethostbyname(config.get(section, 'IP')), config.getint(section, 'PORT')),
|
||||||
'IP': gethostbyname(config.get(section, 'IP')),
|
'IP': gethostbyname(config.get(section, 'IP')),
|
||||||
'PORT': config.getint(section, 'PORT'),
|
'PORT': config.getint(section, 'PORT'),
|
||||||
@ -203,7 +202,6 @@ def build_config(_config_file):
|
|||||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||||
'REPEAT': config.getboolean(section, 'REPEAT'),
|
'REPEAT': config.getboolean(section, 'REPEAT'),
|
||||||
'MAX_PEERS': config.getint(section, 'MAX_PEERS'),
|
'MAX_PEERS': config.getint(section, 'MAX_PEERS'),
|
||||||
'EXPORT_AMBE': config.getboolean(section, 'EXPORT_AMBE'),
|
|
||||||
'IP': gethostbyname(config.get(section, 'IP')),
|
'IP': gethostbyname(config.get(section, 'IP')),
|
||||||
'PORT': config.getint(section, 'PORT'),
|
'PORT': config.getint(section, 'PORT'),
|
||||||
'PASSPHRASE': config.get(section, 'PASSPHRASE'),
|
'PASSPHRASE': config.get(section, 'PASSPHRASE'),
|
||||||
@ -273,4 +271,4 @@ if __name__ == '__main__':
|
|||||||
return _acl[0]
|
return _acl[0]
|
||||||
return not _acl[0]
|
return not _acl[0]
|
||||||
|
|
||||||
print acl_check('\x00\x01\x37', CONFIG['GLOBAL']['TG1_ACL'])
|
print acl_check('\x00\x01\x37', CONFIG['GLOBAL']['TG1_ACL'])
|
||||||
|
@ -234,7 +234,7 @@ class HBSYSTEM(DatagramProtocol):
|
|||||||
for peer in self._peers:
|
for peer in self._peers:
|
||||||
_this_peer = self._peers[peer]
|
_this_peer = self._peers[peer]
|
||||||
# Check to see if any of the peers have been quiet (no ping) longer than allowed
|
# Check to see if any of the peers have been quiet (no ping) longer than allowed
|
||||||
if _this_peer['LAST_PING']+self._CONFIG['GLOBAL']['PING_TIME']*self._CONFIG['GLOBAL']['MAX_MISSED'] < time():
|
if _this_peer['LAST_PING']+(self._CONFIG['GLOBAL']['PING_TIME']*self._CONFIG['GLOBAL']['MAX_MISSED']) < time():
|
||||||
logger.info('(%s) Peer %s (%s) has timed out', self._system, _this_peer['CALLSIGN'], _this_peer['RADIO_ID'])
|
logger.info('(%s) Peer %s (%s) has timed out', self._system, _this_peer['CALLSIGN'], _this_peer['RADIO_ID'])
|
||||||
# Remove any timed out peers from the configuration
|
# Remove any timed out peers from the configuration
|
||||||
del self._CONFIG['SYSTEMS'][self._system]['PEERS'][peer]
|
del self._CONFIG['SYSTEMS'][self._system]['PEERS'][peer]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user