Merge branch 'socket-reporting'

This commit is contained in:
Cort Buffington 2017-06-29 13:03:33 -05:00
commit ae9f71d715
4 changed files with 64 additions and 28 deletions

View File

@ -127,17 +127,29 @@ def build_bridges(_known_bridges):
# are not yet implemented. # are not yet implemented.
def build_acl(_sub_acl): def build_acl(_sub_acl):
try: try:
logger.info('ACL file found, importing entries. This will take about 1.5 seconds per 1 million IDs')
acl_file = import_module(_sub_acl) acl_file = import_module(_sub_acl)
for i, e in enumerate(acl_file.ACL): sections = acl_file.ACL.split(':')
acl_file.ACL[i] = hex_str_3(acl_file.ACL[i]) ACL_ACTION = sections[0]
logger.info('ACL file found and ACL entries imported') entries_str = sections[1]
ACL_ACTION = acl_file.ACL_ACTION ACL = set()
ACL = acl_file.ACL
for entry in entries_str.split(','):
if '-' in entry:
start,end = entry.split('-')
start,end = int(start), int(end)
for id in range(start, end+1):
ACL.add(hex_str_3(id))
else:
id = int(entry)
ACL.add(hex_str_3(id))
logger.info('ACL loaded: action "{}" for {:,} radio IDs'.format(ACL_ACTION, len(ACL)))
except ImportError: except ImportError:
logger.info('ACL file not found or invalid - all subscriber IDs are valid') logger.info('ACL file not found or invalid - all subscriber IDs are valid')
ACL_ACTION = 'NONE' ACL_ACTION = 'NONE'
ACL = []
# Depending on which type of ACL is used (PERMIT, DENY... or there isn't one) # Depending on which type of ACL is used (PERMIT, DENY... or there isn't one)
# define a differnet function to be used to check the ACL # define a differnet function to be used to check the ACL
global allow_sub global allow_sub

View File

@ -149,16 +149,28 @@ def make_bridge_config(_confbridge_rules):
# are not yet implemented. # are not yet implemented.
def build_acl(_sub_acl): def build_acl(_sub_acl):
try: try:
logger.info('ACL file found, importing entries. This will take about 1.5 seconds per 1 million IDs')
acl_file = import_module(_sub_acl) acl_file = import_module(_sub_acl)
for i, e in enumerate(acl_file.ACL): sections = acl_file.ACL.split(':')
acl_file.ACL[i] = hex_str_3(acl_file.ACL[i]) ACL_ACTION = sections[0]
logger.info('ACL file found and ACL entries imported') entries_str = sections[1]
ACL_ACTION = acl_file.ACL_ACTION ACL = set()
ACL = acl_file.ACL_ACTION
for entry in entries_str.split(','):
if '-' in entry:
start,end = entry.split('-')
start,end = int(start), int(end)
for id in range(start, end+1):
ACL.add(hex_str_3(id))
else:
id = int(entry)
ACL.add(hex_str_3(id))
logger.info('ACL loaded: action "{}" for {:,} radio IDs'.format(ACL_ACTION, len(ACL)))
except ImportError: except ImportError:
logger.info('ACL file not found or invalid - all subscriber IDs are valid') logger.info('ACL file not found or invalid - all subscriber IDs are valid')
ACL_ACTION = 'NONE' ACL_ACTION = 'NONE'
ACL = []
# Depending on which type of ACL is used (PERMIT, DENY... or there isn't one) # Depending on which type of ACL is used (PERMIT, DENY... or there isn't one)
# define a differnet function to be used to check the ACL # define a differnet function to be used to check the ACL
@ -352,7 +364,7 @@ class confbridgeIPSC(IPSC):
self.call_start = now self.call_start = now
self._logger.info('(%s) GROUP VOICE START: CallID: %s PEER: %s, SUB: %s, TS: %s, TGID: %s', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group)) self._logger.info('(%s) GROUP VOICE START: CallID: %s PEER: %s, SUB: %s, TS: %s, TGID: %s', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group))
if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK':
self._report.send_bridgeEvent('({}) GROUP VOICE START: CallID: {} PEER: {}, SUB: {}, TS: {}, TGID: {}'.format(self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group))) self._report.send_bridgeEvent('GROUP VOICE,START,{},{},{},{},{},{}'.format(self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group)))
# Action happens on un-key # Action happens on un-key
if _burst_data_type == BURST_DATA_TYPE['VOICE_TERM']: if _burst_data_type == BURST_DATA_TYPE['VOICE_TERM']:
@ -360,11 +372,11 @@ class confbridgeIPSC(IPSC):
self.call_duration = now - self.call_start self.call_duration = now - self.call_start
self._logger.info('(%s) GROUP VOICE END: CallID: %s PEER: %s, SUB: %s, TS: %s, TGID: %s Duration: %.2fs', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group), self.call_duration) self._logger.info('(%s) GROUP VOICE END: CallID: %s PEER: %s, SUB: %s, TS: %s, TGID: %s Duration: %.2fs', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group), self.call_duration)
if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK':
self._report.send_bridgeEvent('({}) GROUP VOICE END: CallID: {} PEER: {}, SUB: {}, TS: {}, TGID: {} Duration: {:.2f}s'.format(self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group), self.call_duration)) self._report.send_bridgeEvent('GROUP VOICE,END,{},{},{},{},{},{},{:.2f}'.format(self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group), self.call_duration))
else: else:
self._logger.warning('(%s) GROUP VOICE END WITHOUT MATCHING START: CallID: %s PEER: %s, SUB: %s, TS: %s, TGID: %s', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group)) self._logger.warning('(%s) GROUP VOICE END WITHOUT MATCHING START: CallID: %s PEER: %s, SUB: %s, TS: %s, TGID: %s', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group))
if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK':
self._report.send_bridgeEvent('(%s) GROUP VOICE END WITHOUT MATCHING START: CallID: %s PEER: %s, SUB: %s, TS: %s, TGID: %s'.format(self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group))) self._report.send_bridgeEvent('GROUP VOICE,UNMATCHED END,{},{},{},{},{},{}'.format(self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group)))
# Iterate the rules dictionary # Iterate the rules dictionary

View File

@ -72,16 +72,28 @@ __email__ = 'n0mjs@me.com'
# are not yet implemented. # are not yet implemented.
def build_acl(_sub_acl): def build_acl(_sub_acl):
try: try:
logger.info('ACL file found, importing entries. This will take about 1.5 seconds per 1 million IDs')
acl_file = import_module(_sub_acl) acl_file = import_module(_sub_acl)
for i, e in enumerate(acl_file.ACL): sections = acl_file.ACL.split(':')
acl_file.ACL[i] = hex_str_3(acl_file.ACL[i]) ACL_ACTION = sections[0]
logger.info('ACL file found and ACL entries imported') entries_str = sections[1]
ACL_ACTION = acl_file.ACL_ACTION ACL = set()
ACL = acl_file.ACL_ACTION
for entry in entries_str.split(','):
if '-' in entry:
start,end = entry.split('-')
start,end = int(start), int(end)
for id in range(start, end+1):
ACL.add(hex_str_3(id))
else:
id = int(entry)
ACL.add(hex_str_3(id))
logger.info('ACL loaded: action "{}" for {:,} radio IDs'.format(ACL_ACTION, len(ACL)))
except ImportError: except ImportError:
logger.info('ACL file not found or invalid - all subscriber IDs are valid') logger.info('ACL file not found or invalid - all subscriber IDs are valid')
ACL_ACTION = 'NONE' ACL_ACTION = 'NONE'
ACL = []
# Depending on which type of ACL is used (PERMIT, DENY... or there isn't one) # Depending on which type of ACL is used (PERMIT, DENY... or there isn't one)
# define a differnet function to be used to check the ACL # define a differnet function to be used to check the ACL

View File

@ -1,6 +1,6 @@
ACL_ACTION = "DENY" # May be PERMIT|DENY # The 'action' May be PERMIT|DENY
ACL = [ # Each entry may be a single radio id, or a hypenated range (e.g. 1-2999)
1234001, # Format:
1234002, # ACL = 'action:id|start-end|,id|start-end,....'
1234003
] ACL = 'DENY:1-2999,16777215'