From 0079ad1baa450a5d315d1e6195267c8d17ac80ac Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Wed, 28 Jun 2017 16:07:29 -0500 Subject: [PATCH 1/7] Change Network Logging Format --- confbridge.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/confbridge.py b/confbridge.py index 5cac329..877aa17 100755 --- a/confbridge.py +++ b/confbridge.py @@ -352,7 +352,7 @@ class confbridgeIPSC(IPSC): 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)) 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 Call Start', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group)]) # Action happens on un-key if _burst_data_type == BURST_DATA_TYPE['VOICE_TERM']: @@ -360,11 +360,11 @@ class confbridgeIPSC(IPSC): 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) 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 Call End', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group), self.call_duration)]) 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)) 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 End Without Matching Start', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group)]) # Iterate the rules dictionary From d1143ddb7cc970e503bd1090a86953efeb8ac8b7 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Wed, 28 Jun 2017 16:11:23 -0500 Subject: [PATCH 2/7] bug fix - last update --- confbridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/confbridge.py b/confbridge.py index 877aa17..e0cceb0 100755 --- a/confbridge.py +++ b/confbridge.py @@ -360,7 +360,7 @@ class confbridgeIPSC(IPSC): 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) if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': - self._report.send_bridgeEvent(['Group Voice Call End', 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 Call End', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group), self.call_duration]) 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)) if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': From 7fde9d1ce8c1710305ad0e39e1901274ba220ae6 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Wed, 28 Jun 2017 16:22:38 -0500 Subject: [PATCH 3/7] Fixing syntax problems in network logging. Incremental --- confbridge.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/confbridge.py b/confbridge.py index e0cceb0..af3ae9b 100755 --- a/confbridge.py +++ b/confbridge.py @@ -352,7 +352,7 @@ class confbridgeIPSC(IPSC): 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)) if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': - self._report.send_bridgeEvent(['Group Voice Call Start', 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 if _burst_data_type == BURST_DATA_TYPE['VOICE_TERM']: @@ -360,11 +360,11 @@ class confbridgeIPSC(IPSC): 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) if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': - self._report.send_bridgeEvent(['Group Voice Call End', 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: 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)) 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)) if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': - self._report.send_bridgeEvent(['Group Voice End Without Matching Start', self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group)]) + 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))) # Iterate the rules dictionary From c8804d72319dbe9ba3ae421eeadcdd9aa86800bb Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Wed, 28 Jun 2017 16:30:15 -0500 Subject: [PATCH 4/7] Network logging format update Make it a format that webtables.py can more easily re-format/manipulate. --- confbridge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/confbridge.py b/confbridge.py index af3ae9b..4cf9b08 100755 --- a/confbridge.py +++ b/confbridge.py @@ -360,11 +360,11 @@ class confbridgeIPSC(IPSC): 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) 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}s'.format(self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group), self.call_duration)) 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)) 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 END WITHOUT MATCHING START:,{},{},{},{},{},{}'.format(self._system, int_id(_seq_id), int_id(_peerid), int_id(_src_sub), _ts, int_id(_dst_group))) # Iterate the rules dictionary From b8d1449d2fb4372066e78f8f4786a9ca5d46a64f Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Wed, 28 Jun 2017 16:32:23 -0500 Subject: [PATCH 5/7] format fix from last update. --- confbridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/confbridge.py b/confbridge.py index 4cf9b08..26040a1 100755 --- a/confbridge.py +++ b/confbridge.py @@ -360,7 +360,7 @@ class confbridgeIPSC(IPSC): 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) if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': - self._report.send_bridgeEvent('GROUP VOICE END,{},{},{},{},{},{},{:.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: 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': From 8fbd7ccf3303deac7850642b66e5d2079de6ed7e Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Wed, 28 Jun 2017 16:35:51 -0500 Subject: [PATCH 6/7] more formatting.... UGH! --- confbridge.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/confbridge.py b/confbridge.py index 26040a1..4c5f9fb 100755 --- a/confbridge.py +++ b/confbridge.py @@ -352,7 +352,7 @@ class confbridgeIPSC(IPSC): 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)) if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': - 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))) + 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 if _burst_data_type == BURST_DATA_TYPE['VOICE_TERM']: @@ -360,11 +360,11 @@ class confbridgeIPSC(IPSC): 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) if self._CONFIG['REPORTS']['REPORT_NETWORKS'] == 'NETWORK': - 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)) + 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: 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': - self._report.send_bridgeEvent('GROUP VOICE END WITHOUT MATCHING START:,{},{},{},{},{},{}'.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 From 4ac862b93c0fb152f7b7b43a4dd682abf94271ee Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Thu, 29 Jun 2017 13:02:53 -0500 Subject: [PATCH 7/7] update ACL format and action to add "ranges" --- bridge.py | 26 +++++++++++++++++++------- confbridge.py | 24 ++++++++++++++++++------ proxy.py | 24 ++++++++++++++++++------ sub_acl_SAMPLE.py | 12 ++++++------ 4 files changed, 61 insertions(+), 25 deletions(-) diff --git a/bridge.py b/bridge.py index d99f436..b0846e7 100755 --- a/bridge.py +++ b/bridge.py @@ -127,17 +127,29 @@ def build_bridges(_known_bridges): # are not yet implemented. def build_acl(_sub_acl): 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) - for i, e in enumerate(acl_file.ACL): - acl_file.ACL[i] = hex_str_3(acl_file.ACL[i]) - logger.info('ACL file found and ACL entries imported') - ACL_ACTION = acl_file.ACL_ACTION - ACL = acl_file.ACL + sections = acl_file.ACL.split(':') + ACL_ACTION = sections[0] + entries_str = sections[1] + ACL = set() + + 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: logger.info('ACL file not found or invalid - all subscriber IDs are valid') ACL_ACTION = 'NONE' - ACL = [] - + # 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 global allow_sub diff --git a/confbridge.py b/confbridge.py index 4c5f9fb..44c9037 100755 --- a/confbridge.py +++ b/confbridge.py @@ -149,16 +149,28 @@ def make_bridge_config(_confbridge_rules): # are not yet implemented. def build_acl(_sub_acl): 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) - for i, e in enumerate(acl_file.ACL): - acl_file.ACL[i] = hex_str_3(acl_file.ACL[i]) - logger.info('ACL file found and ACL entries imported') - ACL_ACTION = acl_file.ACL_ACTION - ACL = acl_file.ACL_ACTION + sections = acl_file.ACL.split(':') + ACL_ACTION = sections[0] + entries_str = sections[1] + ACL = set() + + 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: logger.info('ACL file not found or invalid - all subscriber IDs are valid') ACL_ACTION = 'NONE' - ACL = [] # 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 diff --git a/proxy.py b/proxy.py index 69d10db..2a9eae6 100755 --- a/proxy.py +++ b/proxy.py @@ -72,16 +72,28 @@ __email__ = 'n0mjs@me.com' # are not yet implemented. def build_acl(_sub_acl): 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) - for i, e in enumerate(acl_file.ACL): - acl_file.ACL[i] = hex_str_3(acl_file.ACL[i]) - logger.info('ACL file found and ACL entries imported') - ACL_ACTION = acl_file.ACL_ACTION - ACL = acl_file.ACL_ACTION + sections = acl_file.ACL.split(':') + ACL_ACTION = sections[0] + entries_str = sections[1] + ACL = set() + + 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: logger.info('ACL file not found or invalid - all subscriber IDs are valid') ACL_ACTION = 'NONE' - ACL = [] # 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 diff --git a/sub_acl_SAMPLE.py b/sub_acl_SAMPLE.py index a60fa60..78cedf8 100644 --- a/sub_acl_SAMPLE.py +++ b/sub_acl_SAMPLE.py @@ -1,6 +1,6 @@ -ACL_ACTION = "DENY" # May be PERMIT|DENY -ACL = [ - 1234001, - 1234002, - 1234003 - ] \ No newline at end of file +# The 'action' May be PERMIT|DENY +# Each entry may be a single radio id, or a hypenated range (e.g. 1-2999) +# Format: +# ACL = 'action:id|start-end|,id|start-end,....' + +ACL = 'DENY:1-2999,16777215' \ No newline at end of file