save progress

This commit is contained in:
KF7EEL 2021-06-04 20:06:52 -07:00
parent 949f9b4404
commit 13d86a5b88
2 changed files with 55 additions and 22 deletions

View File

@ -1175,23 +1175,30 @@ def config_reports(_config, _factory):
# configuration file and listed as "active". It can be empty,
# but it has to exist.
def make_bridges(_rules):
global proxy_a_masters
# Convert integer GROUP ID numbers from the config into hex strings
# we need to send in the actual data packets.
for _bridge in _rules:
for _system in _rules[_bridge]:
if _system['SYSTEM'] not in CONFIG['SYSTEMS']:
if _system['SYSTEM'] not in CONFIG['SYSTEMS'] and 'PROXY_' not in _system['SYSTEM']:
sys.exit('ERROR: Conference bridge "{}" references a system named "{}" that is not enabled in the main configuration'.format(_bridge, _system['SYSTEM']))
_system['TGID'] = bytes_3(_system['TGID'])
for i, e in enumerate(_system['ON']):
_system['ON'][i] = bytes_3(_system['ON'][i])
for i, e in enumerate(_system['OFF']):
_system['OFF'][i] = bytes_3(_system['OFF'][i])
_system['TIMEOUT'] = _system['TIMEOUT']*60
if _system['ACTIVE'] == True:
_system['TIMER'] = time() + _system['TIMEOUT']
elif 'PROXY_' in _system['SYSTEM']:
pass
else:
_system['TIMER'] = time()
print(_system['SYSTEM'])
_system['TGID'] = bytes_3(_system['TGID'])
for i, e in enumerate(_system['ON']):
print((i))
print((e))
_system['ON'][i] = bytes_3(_system['ON'][i])
for i, e in enumerate(_system['OFF']):
_system['OFF'][i] = bytes_3(_system['OFF'][i])
_system['TIMEOUT'] = _system['TIMEOUT']*60
if _system['ACTIVE'] == True:
_system['TIMER'] = time() + _system['TIMEOUT']
else:
_system['TIMER'] = time()
#print(_rules)
return _rules
@ -2711,6 +2718,7 @@ class bridgeReportFactory(reportFactory):
#************************************************
if __name__ == '__main__':
#global BRIDGES
import argparse
import sys
import os
@ -2857,22 +2865,19 @@ if __name__ == '__main__':
logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
except (ImportError, FileNotFoundError):
sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
# Build the routing rules file
BRIDGES = make_bridges(rules_module.BRIDGES)
exclude = rules_module.EXCLUDE_FROM_UNIT
# INITIALIZE THE REPORTING LOOP
if CONFIG['REPORTS']['REPORT']:
report_server = config_reports(CONFIG, bridgeReportFactory)
else:
report_server = None
logger.info('(REPORT) TCP Socket reporting not configured')
# HBlink instance creation
logger.info('(GLOBAL) HBlink \'bridge.py\' -- SYSTEM STARTING...')
proxy_a_masters = []
proxy_b_masters = []
proxy_c_masters = []
if CONFIG['PROXY_A']['ENABLED']:
#generate_proxy_masters()
n_systems = CONFIG['PROXY_A']['INTERNAL_PORT_STOP'] - CONFIG['PROXY_A']['INTERNAL_PORT_START']
@ -2897,6 +2902,7 @@ if __name__ == '__main__':
}})
CONFIG['SYSTEMS'][CONFIG['PROXY_A']['NAME'] + '-' + str(n_count)].update({'PEERS': {}})
systems[CONFIG['PROXY_A']['NAME'] + '-' + str(n_count)] = routerHBP(CONFIG['PROXY_A']['NAME'] + '-' + str(n_count), CONFIG, report_server)
proxy_a_masters.append(CONFIG['PROXY_A']['NAME'] + '-' + str(n_count))
n_count = n_count + 1
if CONFIG['PROXY_B']['ENABLED']:
@ -2923,6 +2929,7 @@ if __name__ == '__main__':
}})
CONFIG['SYSTEMS'][CONFIG['PROXY_B']['NAME'] + '-' + str(n_count)].update({'PEERS': {}})
systems[CONFIG['PROXY_B']['NAME'] + '-' + str(n_count)] = routerHBP(CONFIG['PROXY_B']['NAME'] + '-' + str(n_count), CONFIG, report_server)
proxy_b_masters.append(CONFIG['PROXY_B']['NAME'] + '-' + str(n_count))
n_count = n_count + 1
if CONFIG['PROXY_C']['ENABLED']:
#generate_proxy_masters()
@ -2948,6 +2955,7 @@ if __name__ == '__main__':
}})
CONFIG['SYSTEMS'][CONFIG['PROXY_C']['NAME'] + '-' + str(n_count)].update({'PEERS': {}})
systems[CONFIG['PROXY_C']['NAME'] + '-' + str(n_count)] = routerHBP(CONFIG['PROXY_C']['NAME'] + '-' + str(n_count), CONFIG, report_server)
proxy_c_masters.append(CONFIG['PROXY_c']['NAME'] + '-' + str(n_count))
n_count = n_count + 1
for system in CONFIG['SYSTEMS']:
@ -2965,7 +2973,34 @@ if __name__ == '__main__':
logger.error('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error in timed loop.\n %s', failure)
reactor.stop()
# Build the routing rules file
bridge_dict = rules_module.BRIDGES
print(bridge_dict)
for b in bridge_dict:
for s in bridge_dict[b]:
if s['SYSTEM'] == 'PROXY_A':
for m in proxy_a_masters:
print(type(s['ON']))
bridge_dict[b].append({'SYSTEM': m, 'TS': s['TS'], 'TGID': s['TGID'], 'ACTIVE': s['ACTIVE'], 'TIMEOUT': s['TIMEOUT'], 'TO_TYPE': s['TO_TYPE'], 'ON': [1], 'OFF': s['OFF'], 'RESET': s['RESET']})
# bridge_dict[b].remove(s)
if s['SYSTEM'] == 'PROXY_B':
for m in proxy_b_masters:
bridge_dict[b].append({'SYSTEM': m, 'TS': s['TS'], 'TGID': s['TGID'], 'ACTIVE': s['ACTIVE'], 'TIMEOUT': s['TIMEOUT'], 'TO_TYPE': s['TO_TYPE'], 'ON': [1], 'OFF': s['OFF'], 'RESET': s['RESET']})
# bridge_dict[b].remove(s)
if s['SYSTEM'] == 'PROXY_C':
for m in proxy_c_masters:
bridge_dict[b].append({'SYSTEM': m, 'TS': s['TS'], 'TGID': s['TGID'], 'ACTIVE': s['ACTIVE'], 'TIMEOUT': s['TIMEOUT'], 'TO_TYPE': s['TO_TYPE'], 'ON': [1], 'OFF': s['OFF'], 'RESET': s['RESET']})
# bridge_dict[b].remove(s)
BRIDGES = make_bridges(bridge_dict)
print(bridge_dict)
print()
print(BRIDGES)
exclude = rules_module.EXCLUDE_FROM_UNIT
# Get rule parameter for private calls
#UNIT = rules_module.UNIT
UNIT = build_unit(CONFIG)
@ -3010,4 +3045,5 @@ if __name__ == '__main__':
proxy_thread.start()
logger.info('Unit calls will be bridged to: ' + str(UNIT))
# print(BRIDGES)
reactor.run()

View File

@ -62,13 +62,10 @@ class Proxy(DatagramProtocol):
nowtime = time()
Debug = self.debug
print(host)
print(self.master)
#If the packet comes from the master
if host == self.master:
_command = data[:4]
print(data)
if _command == DMRD:
_peer_id = data[11:15]