work on MASTER generation

This commit is contained in:
KF7EEL 2021-05-28 12:29:55 -07:00
parent 20444b7de0
commit 0698417682
3 changed files with 99 additions and 15 deletions

View File

@ -303,16 +303,24 @@ TGID_TS2_ACL: PERMIT:ALL
# Utilizing the hotspot proxy from FreeDMR
##[PROXY_TEMPLATE]
##STATIC_APRS_POSITION_ENABLED: False
##REPEAT: True
##PASSPHRASE: password
##GROUP_HANGTIME: 5
##USE_ACL: True
##REG_ACL: DENY:1
##SUB_ACL: DENY:1
##TGID_TS1_ACL: PERMIT:ALL
##TGID_TS2_ACL: PERMIT:ALL
[PROXY_TEMPLATE]
ENABLED: True
# Port that clients will connect on.
EXTERNAL_PORT: 62032
# Internal ports used for generated master instances.
INTERNAL_PORT_START: 54000
INTERNAL_PORT_STOP: 54010
STATIC_APRS_POSITION_ENABLED: False
REPEAT: True
PASSPHRASE: password
GROUP_HANGTIME: 5
USE_ACL: True
REG_ACL: DENY:1
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL

View File

@ -2814,11 +2814,6 @@ if __name__ == '__main__':
BRIDGES = make_bridges(rules_module.BRIDGES)
exclude = rules_module.EXCLUDE_FROM_UNIT
# Get rule parameter for private calls
#UNIT = rules_module.UNIT
UNIT = build_unit(CONFIG)
UNIT_MAP = build_unit_map(CONFIG)
# INITIALIZE THE REPORTING LOOP
if CONFIG['REPORTS']['REPORT']:
report_server = config_reports(CONFIG, bridgeReportFactory)
@ -2828,12 +2823,66 @@ if __name__ == '__main__':
# HBlink instance creation
logger.info('(GLOBAL) HBlink \'bridge.py\' -- SYSTEM STARTING...')
# Generates a series of MASTER instances for use with hotspot proxy from FreeDMR
def generate_proxy_masters():
n_systems = CONFIG['PROXY_TEMPLATE']['INTERNAL_PORT_STOP'] - CONFIG['PROXY_TEMPLATE']['INTERNAL_PORT_START']
n_count = 0
while n_count < n_systems:
CONFIG['SYSTEMS'].update({'MMDVM-' + str(n_count): {
'MODE': 'MASTER',
'ENABLED': True,
'STATIC_APRS_POSITION_ENABLED': CONFIG['PROXY_TEMPLATE']['STATIC_APRS_POSITION_ENABLED'],
'REPEAT': CONFIG['PROXY_TEMPLATE']['REPEAT'],
'MAX_PEERS': 1,
'IP': '127.0.0.1',
'PORT': CONFIG['PROXY_TEMPLATE']['INTERNAL_PORT_START'] + n_count,
'PASSPHRASE': CONFIG['PROXY_TEMPLATE']['PASSPHRASE'],
'GROUP_HANGTIME': CONFIG['PROXY_TEMPLATE']['GROUP_HANGTIME'],
'USE_ACL': CONFIG['PROXY_TEMPLATE']['USE_ACL'],
'REG_ACL': CONFIG['PROXY_TEMPLATE']['REG_ACL'],
'SUB_ACL': CONFIG['PROXY_TEMPLATE']['SUB_ACL'],
'TG1_ACL': CONFIG['PROXY_TEMPLATE']['TG1_ACL'],
'TG2_ACL': CONFIG['PROXY_TEMPLATE']['TG2_ACL']
}})
CONFIG['SYSTEMS']['MMDVM-' + str(n_count)].update({'PEERS': {}})
systems['MMDVM-' + str(n_count)] = routerHBP(system, CONFIG, report_server)
n_count = n_count + 1
if CONFIG['PROXY_TEMPLATE']['ENABLED']:
#generate_proxy_masters()
n_systems = CONFIG['PROXY_TEMPLATE']['INTERNAL_PORT_STOP'] - CONFIG['PROXY_TEMPLATE']['INTERNAL_PORT_START']
n_count = 0
while n_count < n_systems:
CONFIG['SYSTEMS'].update({'MMDVM-' + str(n_count): {
'MODE': 'MASTER',
'ENABLED': True,
'STATIC_APRS_POSITION_ENABLED': CONFIG['PROXY_TEMPLATE']['STATIC_APRS_POSITION_ENABLED'],
'REPEAT': CONFIG['PROXY_TEMPLATE']['REPEAT'],
'MAX_PEERS': 1,
'IP': '127.0.0.1',
'PORT': CONFIG['PROXY_TEMPLATE']['INTERNAL_PORT_START'] + n_count,
'PASSPHRASE': CONFIG['PROXY_TEMPLATE']['PASSPHRASE'],
'GROUP_HANGTIME': CONFIG['PROXY_TEMPLATE']['GROUP_HANGTIME'],
'USE_ACL': CONFIG['PROXY_TEMPLATE']['USE_ACL'],
'REG_ACL': CONFIG['PROXY_TEMPLATE']['REG_ACL'],
'SUB_ACL': CONFIG['PROXY_TEMPLATE']['SUB_ACL'],
'TG1_ACL': CONFIG['PROXY_TEMPLATE']['TG1_ACL'],
'TG2_ACL': CONFIG['PROXY_TEMPLATE']['TG2_ACL']
}})
CONFIG['SYSTEMS']['MMDVM-' + str(n_count)].update({'PEERS': {}})
systems['MMDVM-' + str(n_count)] = routerHBP('MMDVM-' + str(n_count), CONFIG, report_server)
n_count = n_count + 1
for system in CONFIG['SYSTEMS']:
print((CONFIG['SYSTEMS']))
if CONFIG['SYSTEMS'][system]['ENABLED']:
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':
systems[system] = routerOBP(system, CONFIG, report_server)
else:
systems[system] = routerHBP(system, CONFIG, report_server)
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
logger.debug('(GLOBAL) %s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
logger.info(systems)
@ -2842,6 +2891,12 @@ if __name__ == '__main__':
logger.error('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error in timed loop.\n %s', failure)
reactor.stop()
# Get rule parameter for private calls
#UNIT = rules_module.UNIT
UNIT = build_unit(CONFIG)
UNIT_MAP = build_unit_map(CONFIG)
# Initialize the rule timer -- this if for user activated stuff
rule_timer_task = task.LoopingCall(rule_timer_loop)
rule_timer = rule_timer_task.start(60)

View File

@ -109,6 +109,8 @@ def build_config(_config_file):
CONFIG['GPS_DATA'] = {}
CONFIG['ALIASES'] = {}
CONFIG['SYSTEMS'] = {}
CONFIG['PROXY_TEMPLATE'] = {}
try:
for section in config.sections():
@ -197,6 +199,25 @@ def build_config(_config_file):
'STALE_TIME': config.getint(section, 'STALE_DAYS') * 86400,
})
elif section == 'PROXY_TEMPLATE':
CONFIG['PROXY_TEMPLATE'].update({
'ENABLED': config.getboolean(section, 'ENABLED'),
'REPEAT': config.getboolean(section, 'REPEAT'),
'EXTERNAL_PORT': config.getint(section, 'EXTERNAL_PORT'),
'INTERNAL_PORT_START': config.getint(section, 'INTERNAL_PORT_START'),
'INTERNAL_PORT_STOP': config.getint(section, 'INTERNAL_PORT_STOP'),
'STATIC_APRS_POSITION_ENABLED': config.getboolean(section, 'STATIC_APRS_POSITION_ENABLED'),
'PASSPHRASE': bytes(config.get(section, 'PASSPHRASE'), 'utf-8'),
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
'USE_ACL': config.getboolean(section, 'USE_ACL'),
'REG_ACL': config.get(section, 'REG_ACL'),
'SUB_ACL': config.get(section, 'SUB_ACL'),
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
'TG2_ACL': config.get(section, 'TGID_TS2_ACL')
})
elif config.getboolean(section, 'ENABLED'):
if config.get(section, 'MODE') == 'PEER':
CONFIG['SYSTEMS'].update({section: {