|
|
|
|
@ -39,7 +39,6 @@ import importlib.util
|
|
|
|
|
import re
|
|
|
|
|
import copy
|
|
|
|
|
from setproctitle import setproctitle
|
|
|
|
|
from collections import deque
|
|
|
|
|
|
|
|
|
|
#from crccheck.crc import Crc32
|
|
|
|
|
from hashlib import blake2b
|
|
|
|
|
@ -84,9 +83,9 @@ from binascii import b2a_hex as ahex
|
|
|
|
|
from AMI import AMI
|
|
|
|
|
|
|
|
|
|
#debugging and profiling
|
|
|
|
|
#import gc
|
|
|
|
|
import gc
|
|
|
|
|
|
|
|
|
|
#gc.set_debug(gc.DEBUG_LEAK | gc.DEBUG_STATS)
|
|
|
|
|
gc.set_debug(gc.DEBUG_LEAK | gc.DEBUG_STATS)
|
|
|
|
|
|
|
|
|
|
##from hmac import new as hmac_new, compare_digest
|
|
|
|
|
##from hashlib import sha256, hash
|
|
|
|
|
@ -240,7 +239,7 @@ def make_default_reflector(reflector,_tmout,system):
|
|
|
|
|
if bridge not in BRIDGES:
|
|
|
|
|
BRIDGES[bridge] = []
|
|
|
|
|
make_single_reflector(bytes_3(reflector),_tmout, system)
|
|
|
|
|
bridgetemp = deque()
|
|
|
|
|
bridgetemp = []
|
|
|
|
|
for bridgesystem in BRIDGES[bridge]:
|
|
|
|
|
if bridgesystem['SYSTEM'] == system and bridgesystem['TS'] == 2:
|
|
|
|
|
bridgetemp.append({'SYSTEM': system, 'TS': 2, 'TGID': bytes_3(9),'ACTIVE': True,'TIMEOUT': _tmout * 60,'TO_TYPE': 'OFF','OFF': [],'ON': [bytes_3(reflector),],'RESET': [], 'TIMER': time() + (_tmout * 60)})
|
|
|
|
|
@ -253,7 +252,7 @@ def make_static_tg(tg,ts,_tmout,system):
|
|
|
|
|
#_tmout = CONFIG['SYSTEMS'][system]['DEFAULT_UA_TIMER']
|
|
|
|
|
if str(tg) not in BRIDGES:
|
|
|
|
|
make_single_bridge(bytes_3(tg),system,ts,_tmout)
|
|
|
|
|
bridgetemp = deque()
|
|
|
|
|
bridgetemp = []
|
|
|
|
|
for bridgesystem in BRIDGES[str(tg)]:
|
|
|
|
|
if bridgesystem['SYSTEM'] == system and bridgesystem['TS'] == ts:
|
|
|
|
|
bridgetemp.append({'SYSTEM': system, 'TS': ts, 'TGID': bytes_3(tg),'ACTIVE': True,'TIMEOUT': _tmout * 60,'TO_TYPE': 'OFF','OFF': [],'ON': [bytes_3(tg),],'RESET': [], 'TIMER': time() + (_tmout * 60)})
|
|
|
|
|
@ -264,7 +263,7 @@ def make_static_tg(tg,ts,_tmout,system):
|
|
|
|
|
|
|
|
|
|
def reset_static_tg(tg,ts,_tmout,system):
|
|
|
|
|
#_tmout = CONFIG['SYSTEMS'][system]['DEFAULT_UA_TIMER']
|
|
|
|
|
bridgetemp = deque()
|
|
|
|
|
bridgetemp = []
|
|
|
|
|
try:
|
|
|
|
|
for bridgesystem in BRIDGES[str(tg)]:
|
|
|
|
|
if bridgesystem['SYSTEM'] == system and bridgesystem['TS'] == ts:
|
|
|
|
|
@ -283,7 +282,7 @@ def reset_default_reflector(reflector,_tmout,system):
|
|
|
|
|
if bridge not in BRIDGES:
|
|
|
|
|
BRIDGES[bridge] = []
|
|
|
|
|
make_single_reflector(bytes_3(reflector),_tmout, system)
|
|
|
|
|
bridgetemp = deque()
|
|
|
|
|
bridgetemp = []
|
|
|
|
|
for bridgesystem in BRIDGES[bridge]:
|
|
|
|
|
if bridgesystem['SYSTEM'] == system and bridgesystem['TS'] == 2:
|
|
|
|
|
bridgetemp.append({'SYSTEM': system, 'TS': 2, 'TGID': bytes_3(9),'ACTIVE': False,'TIMEOUT': _tmout * 60,'TO_TYPE': 'ON','OFF': [],'ON': [bytes_3(reflector),],'RESET': [], 'TIMER': time() + (_tmout * 60)})
|
|
|
|
|
@ -325,7 +324,7 @@ def remove_bridge_system(system):
|
|
|
|
|
def rule_timer_loop():
|
|
|
|
|
logger.debug('(ROUTER) routerHBP Rule timer loop started')
|
|
|
|
|
_now = time()
|
|
|
|
|
_remove_bridges = deque()
|
|
|
|
|
_remove_bridges = []
|
|
|
|
|
for _bridge in BRIDGES:
|
|
|
|
|
_bridge_used = False
|
|
|
|
|
for _system in BRIDGES[_bridge]:
|
|
|
|
|
@ -375,7 +374,7 @@ def rule_timer_loop():
|
|
|
|
|
|
|
|
|
|
def statTrimmer():
|
|
|
|
|
logger.debug('(ROUTER) STAT trimmer loop started')
|
|
|
|
|
_remove_bridges = deque()
|
|
|
|
|
_remove_bridges = []
|
|
|
|
|
for _bridge in BRIDGES:
|
|
|
|
|
_bridge_stat = False
|
|
|
|
|
_in_use = False
|
|
|
|
|
@ -395,7 +394,7 @@ def statTrimmer():
|
|
|
|
|
report_server.send_clients(b'bridge updated')
|
|
|
|
|
|
|
|
|
|
#Run garbage collector manually
|
|
|
|
|
#gc.collect()
|
|
|
|
|
gc.collect()
|
|
|
|
|
|
|
|
|
|
def kaReporting():
|
|
|
|
|
logger.debug('(ROUTER) KeepAlive reporting loop started')
|
|
|
|
|
@ -422,7 +421,7 @@ def subMapWrite():
|
|
|
|
|
def SubMapTrimmer():
|
|
|
|
|
logger.debug('(SUBSCRIBER) Subscriber Map trimmer loop started')
|
|
|
|
|
_sub_time = time()
|
|
|
|
|
_remove_list = deque()
|
|
|
|
|
_remove_list = []
|
|
|
|
|
for _subscriber in SUB_MAP:
|
|
|
|
|
if SUB_MAP[_subscriber][2] < (_sub_time - 86400):
|
|
|
|
|
_remove_list.append(_subscriber)
|
|
|
|
|
@ -471,8 +470,8 @@ def stream_trimmer_loop():
|
|
|
|
|
# OBP systems
|
|
|
|
|
# We can't delete items from a dicationry that's being iterated, so we have to make a temporarly list of entrys to remove later
|
|
|
|
|
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
|
|
|
|
|
remove_list = deque()
|
|
|
|
|
fin_list = deque()
|
|
|
|
|
remove_list = []
|
|
|
|
|
fin_list = []
|
|
|
|
|
for stream_id in systems[system].STATUS:
|
|
|
|
|
|
|
|
|
|
#if stream already marked as finished, just remove it
|
|
|
|
|
@ -534,7 +533,7 @@ def stream_trimmer_loop():
|
|
|
|
|
removed = systems[system].STATUS.pop(stream_id)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
_bcsq_remove = deque()
|
|
|
|
|
_bcsq_remove = []
|
|
|
|
|
for tgid in _sysconfig['_bcsq']:
|
|
|
|
|
if _sysconfig['_bcsq'][tgid] == stream_id:
|
|
|
|
|
_bcsq_remove.append(tgid)
|
|
|
|
|
@ -1862,7 +1861,7 @@ class routerOBP(OPENBRIDGE):
|
|
|
|
|
logger.debug('(%s) Bridge for STAT TG %s does not exist. Creating',self._system, int_id(_dst_id))
|
|
|
|
|
make_stat_bridge(_dst_id)
|
|
|
|
|
|
|
|
|
|
_sysIgnore = deque()
|
|
|
|
|
_sysIgnore = []
|
|
|
|
|
for _bridge in BRIDGES:
|
|
|
|
|
for _system in BRIDGES[_bridge]:
|
|
|
|
|
|
|
|
|
|
@ -2668,7 +2667,7 @@ class routerHBP(HBSYSTEM):
|
|
|
|
|
#Save this packet
|
|
|
|
|
self.STATUS[_slot]['lastData'] = _data
|
|
|
|
|
|
|
|
|
|
_sysIgnore = deque()
|
|
|
|
|
_sysIgnore = []
|
|
|
|
|
for _bridge in BRIDGES:
|
|
|
|
|
#if _bridge[0:1] != '#':
|
|
|
|
|
if True:
|
|
|
|
|
@ -2977,7 +2976,7 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
#Generator
|
|
|
|
|
generator = {}
|
|
|
|
|
systemdelete = deque()
|
|
|
|
|
systemdelete = []
|
|
|
|
|
for system in CONFIG['SYSTEMS']:
|
|
|
|
|
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
|
|
|
|
if CONFIG['SYSTEMS'][system]['MODE'] == 'MASTER' and (CONFIG['SYSTEMS'][system]['GENERATOR'] > 1):
|
|
|
|
|
|