|
|
|
@ -33,7 +33,6 @@ This program currently only works with group voice calls.
|
|
|
|
|
|
|
|
|
|
|
|
# Python modules we need
|
|
|
|
# Python modules we need
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import json
|
|
|
|
|
|
|
|
from bitarray import bitarray
|
|
|
|
from bitarray import bitarray
|
|
|
|
from time import time,sleep,perf_counter
|
|
|
|
from time import time,sleep,perf_counter
|
|
|
|
import importlib.util
|
|
|
|
import importlib.util
|
|
|
|
@ -396,14 +395,13 @@ def kaReporting():
|
|
|
|
|
|
|
|
|
|
|
|
#Write SUB_MAP to disk
|
|
|
|
#Write SUB_MAP to disk
|
|
|
|
def subMapWrite():
|
|
|
|
def subMapWrite():
|
|
|
|
_json = json.dumps(SUB_MAP)
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
_file = open(CONFIG['ALIASES']['SUB_MAP_FILE'],'w')
|
|
|
|
_fh = open(CONFIG['ALIASES']['SUB_MAP_FILE'],'wb')
|
|
|
|
_file.write(_json)
|
|
|
|
pickle.dump(SUB_MAP,_fh)
|
|
|
|
_file.close()
|
|
|
|
_fh.close()
|
|
|
|
logger.info('(SUBSCRIBER) Writing SUB_MAP to disk %s',_json)
|
|
|
|
logger.info('(SUBSCRIBER) Writing SUB_MAP to disk')
|
|
|
|
except IOError:
|
|
|
|
except:
|
|
|
|
logger.warning('(SUBSCRIBER) Cannot write SUB_MAP to file: IOError')
|
|
|
|
logger.warning('(SUBSCRIBER) Cannot write SUB_MAP to file')
|
|
|
|
|
|
|
|
|
|
|
|
#Subscriber Map trimmer loop
|
|
|
|
#Subscriber Map trimmer loop
|
|
|
|
def SubMapTrimmer():
|
|
|
|
def SubMapTrimmer():
|
|
|
|
@ -411,12 +409,11 @@ def SubMapTrimmer():
|
|
|
|
_sub_time = time()
|
|
|
|
_sub_time = time()
|
|
|
|
_remove_list = []
|
|
|
|
_remove_list = []
|
|
|
|
for _subscriber in SUB_MAP:
|
|
|
|
for _subscriber in SUB_MAP:
|
|
|
|
if _subscriber[2] < (_sub_time - 86400):
|
|
|
|
if SUB_MAP[_subscriber][2] < (_sub_time - 86400):
|
|
|
|
_remove_list.append(_subscriber)
|
|
|
|
_remove_list.append(_subscriber)
|
|
|
|
|
|
|
|
|
|
|
|
for _remove in _remove_list:
|
|
|
|
for _remove in _remove_list:
|
|
|
|
SUB_MAP.pop(_remove)
|
|
|
|
SUB_MAP.pop(_remove)
|
|
|
|
|
|
|
|
|
|
|
|
if CONFIG['ALIASES']['SUB_MAP_FILE']:
|
|
|
|
if CONFIG['ALIASES']['SUB_MAP_FILE']:
|
|
|
|
subMapWrite()
|
|
|
|
subMapWrite()
|
|
|
|
|
|
|
|
|
|
|
|
@ -2637,13 +2634,17 @@ if __name__ == '__main__':
|
|
|
|
#SUB_MAP = {bytes_3(73578):('REP-1',1,time())}
|
|
|
|
#SUB_MAP = {bytes_3(73578):('REP-1',1,time())}
|
|
|
|
SUB_MAP = {}
|
|
|
|
SUB_MAP = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if CONFIG['ALIASES']['SUB_MAP_FILE']:
|
|
|
|
if CONFIG['ALIASES']['SUB_MAP_FILE']:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
with open(CONFIG['ALIASES']['SUB_MAP_FILE']) as _json_file:
|
|
|
|
with open(CONFIG['ALIASES']['SUB_MAP_FILE'],'rb') as _fh:
|
|
|
|
SUB_MAP = json.load(_json_file)
|
|
|
|
SUB_MAP = pickle.load(_fh)
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
logger.warning('(SUBSCRIBER) Cannot load SUB_MAP file')
|
|
|
|
logger.warning('(SUBSCRIBER) Cannot load SUB_MAP file')
|
|
|
|
#sys.exit('(SUBSCRIBER) TERMINATING: SUB_MAP file not found or invalid')
|
|
|
|
#sys.exit('(SUBSCRIBER) TERMINATING: SUB_MAP file not found or invalid')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Test value
|
|
|
|
|
|
|
|
#SUB_MAP[bytes_3(73578)] = ('REP-1',1,time())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Generator
|
|
|
|
#Generator
|
|
|
|
|