From c761e740bc2c8d35f006705d34a9e9592594dbbb Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Fri, 18 Jun 2021 13:25:55 -0700 Subject: [PATCH] fis USER_MANAGER section of config --- bridge.py | 38 +++------ hblink.py | 2 +- user_managment/app.py | 180 ++++++++++++++++++++++-------------------- 3 files changed, 109 insertions(+), 111 deletions(-) diff --git a/bridge.py b/bridge.py index 4b14b0e..91ae299 100755 --- a/bridge.py +++ b/bridge.py @@ -156,7 +156,15 @@ def download_config(L_CONFIG_FILE, cli_file): iterate_config.update(resp['masters'].copy()) corrected_config['SYSTEMS'].update(iterate_config) corrected_config['LOGGER'].update(L_CONFIG_FILE['LOGGER']) - corrected_config['USER_MANAGER'].update(L_CONFIG_FILE['USER_MANAGER']) +## corrected_config['USER_MANAGER'].update(resp['config']['USER_MANAGER']) +## print(resp['config']['USER_MANAGER']) + corrected_config['USER_MANAGER'] = {} + corrected_config['USER_MANAGER']['THIS_SERVER_NAME'] = L_CONFIG_FILE['USER_MANAGER']['THIS_SERVER_NAME'] + corrected_config['USER_MANAGER']['URL'] = L_CONFIG_FILE['USER_MANAGER']['URL'] + corrected_config['USER_MANAGER']['SHARED_SECRET'] = L_CONFIG_FILE['USER_MANAGER']['SHARED_SECRET'] + corrected_config['USER_MANAGER']['REMOTE_CONFIG_ENABLED'] = L_CONFIG_FILE['USER_MANAGER']['REMOTE_CONFIG_ENABLED'] + corrected_config['USER_MANAGER'].update(resp['config']['USER_MANAGER']) + ## iterate_config.update(resp['masters'].copy()) ## print(iterate_config) ## print(iterate_config) @@ -238,13 +246,7 @@ def download_config(L_CONFIG_FILE, cli_file): corrected_config['SYSTEMS'][i]['USE_ACL'] = iterate_config[i]['USE_ACL'] corrected_config['SYSTEMS'][i]['SUB_ACL'] = config.acl_build(iterate_config[i]['SUB_ACL'], 16776415) - -## print(iterate_masters) -## for i in iterate_masters: -## iterate_masters['SYSTEMS'] -## config.process_acls(corrected_config) -## print(corrected_config['SYSTEMS']) -## print('-------') +## print(corrected_config) return corrected_config # For exception, write blank dict except requests.ConnectionError: @@ -825,6 +827,7 @@ class routerHBP(HBSYSTEM): def __init__(self, _name, _config, _report): HBSYSTEM.__init__(self, _name, _config, _report) +## print(_config) self.name = _name # list of self._targets for unit (subscriber, private) calls @@ -1352,26 +1355,12 @@ if __name__ == '__main__': # Call the external routine to build the configuration dictionary LOCAL_CONFIG = config.build_config(cli_args.CONFIG_FILE) - #print(LOCAL_CONFIG) - #print(download_config(LOCAL_CONFIG)) - #if LOCAL_CONFIG['USER_MANAGER']['REMOTE_CONFIG_ENABLED']: - #print(download_config(LOCAL_CONFIG)['config']) -## CONFIG = config.build_config(download_config(LOCAL_CONFIG)) - #CONFIG = download_config(LOCAL_CONFIG) - #if not LOCAL_CONFIG['USER_MANAGER']['REMOTE_CONFIG_ENABLED']: -## print(download_config(LOCAL_CONFIG)['config']) -## CONFIG = config.build_config(cli_args.CONFIG_FILE) - #print((CONFIG)) - - -## config.process_acls(LOCAL_CONFIG) if LOCAL_CONFIG['USER_MANAGER']['REMOTE_CONFIG_ENABLED']: CONFIG = download_config(LOCAL_CONFIG, cli_args.CONFIG_FILE) + print('enabled') else: CONFIG = config.build_config(cli_args.CONFIG_FILE) - -## print(CONFIG) # Ensure we have a path for the rules file, if one wasn't specified, then use the default (top of file) if not cli_args.RULES_FILE: @@ -1486,8 +1475,7 @@ if __name__ == '__main__': BRIDGES = make_bridges(rules_module.BRIDGES) # Get rule parameter for private calls UNIT = rules_module.UNIT - - + for system in CONFIG['SYSTEMS']: if CONFIG['SYSTEMS'][system]['ENABLED']: if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE': diff --git a/hblink.py b/hblink.py index 70b6a52..50fb44d 100755 --- a/hblink.py +++ b/hblink.py @@ -339,7 +339,7 @@ class HBSYSTEM(DatagramProtocol): if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == False: pass _calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest()) -## print(calc_passphrase) + print(calc_passphrase) # print(_calc_hash) return _calc_hash diff --git a/user_managment/app.py b/user_managment/app.py index b26f4c0..4c2cf42 100644 --- a/user_managment/app.py +++ b/user_managment/app.py @@ -571,95 +571,95 @@ def create_app(): @login_required def gen(): #print(str(gen_passphrase(3153591))) #(int(i[0]))) -## try: + try: #content = Markup('The HTML String') #user_id = request.args.get('user_id') - u = current_user -## print(u.username) - id_dict = ast.literal_eval(u.dmr_ids) - #u = User.query.filter_by(username=user).first() -## print(user_id) -## print(request.args.get('mode')) -## if request.args.get('mode') == 'generated': - #print(id_dict) - content = '\n' - for i in id_dict.items(): - if isinstance(i[1], int) == True and i[1] != 0: - link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8) - script_links[i[0]] = link_num - #print(script_links) - content = content + '''\n - - - - + + +
-

Your passphrase for ''' + str(i[0]) + ''':

-

Copy and paste: ''' + str(gen_passphrase(int(i[0]))) + '''

-
+ u = current_user + ## print(u.username) + id_dict = ast.literal_eval(u.dmr_ids) + #u = User.query.filter_by(username=user).first() + ## print(user_id) + ## print(request.args.get('mode')) + ## if request.args.get('mode') == 'generated': + #print(id_dict) + content = '\n' + for i in id_dict.items(): + if isinstance(i[1], int) == True and i[1] != 0: + link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8) + script_links[i[0]] = link_num + #print(script_links) + content = content + '''\n + + + + - - -
+

Your passphrase for ''' + str(i[0]) + ''':

+

Copy and paste: ''' + str(gen_passphrase(int(i[0]))) + '''

+
-

Phonetically spelled: ''' + convert_nato(str(gen_passphrase(int(i[0])))) + '''

+

Phonetically spelled: ''' + convert_nato(str(gen_passphrase(int(i[0])))) + '''

-
-

 

+
+

 

+ ''' + elif i[1] == 0: + link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8) + script_links[i[0]] = link_num + #print(script_links) + content = content + '''\n + + + + + + +
+

Your passphrase for ''' + str(i[0]) + ''':

+

Copy and paste: ''' + str(gen_passphrase(int(i[0]))) + '''

+
+ +

Phonetically spelled: ''' + convert_nato(str(gen_passphrase(int(i[0])))) + '''

+ +
+

 

+ ''' + elif i[1] == '': + content = content + ''' + + + + + + +
+

Your passphrase for ''' + str(i[0]) + ''':

+

Copy and paste: ''' + legacy_passphrase + '''

+
+

Phonetically spelled: ''' + convert_nato(legacy_passphrase) + '''

+
+

 

''' + else: + content = content + ''' + + + + + + +
+

Your passphrase for ''' + str(i[0]) + ''':

+

Copy and paste: ''' + str(i[1]) + '''

+
+

Phonetically spelled: ''' + convert_nato(str(i[1])) + '''

+
+

 

''' - elif i[1] == 0: - link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8) - script_links[i[0]] = link_num - #print(script_links) - content = content + '''\n - - - - - - -
-

Your passphrase for ''' + str(i[0]) + ''':

-

Copy and paste: ''' + str(gen_passphrase(int(i[0]))) + '''

-
- -

Phonetically spelled: ''' + convert_nato(str(gen_passphrase(int(i[0])))) + '''

- -
-

 

- ''' - elif i[1] == '': - content = content + ''' - - - - - - -
-

Your passphrase for ''' + str(i[0]) + ''':

-

Copy and paste: ''' + legacy_passphrase + '''

-
-

Phonetically spelled: ''' + convert_nato(legacy_passphrase) + '''

-
-

 

''' - else: - content = content + ''' - - - - - - -
-

Your passphrase for ''' + str(i[0]) + ''':

-

Copy and paste: ''' + str(i[1]) + '''

-
-

Phonetically spelled: ''' + convert_nato(str(i[1])) + '''

-
-

 

-''' #content = content + '\n\n' + str(script_links[i[0]]) -## except: -## content = Markup('No DMR IDs found or other error.') + except: + content = Markup('No DMR IDs found or other error.') #return str(content) @@ -1987,6 +1987,12 @@ def create_app(): 'STALE_TIME': i.ai_stale * 86400, }) s_config['USER_MANAGER'].update({ + 'SHORTEN_LENGTH': shorten_length, + 'SHORTEN_SAMPLE': shorten_sample, + 'EXTRA_1': extra_1, + 'EXTRA_2': extra_2, + 'EXTRA_INT_1': extra_int_1, + 'EXTRA_INT_2': extra_int_2, 'APPEND_INT': append_int, 'SHORTEN_PASSPHRASE': i.um_shorten_passphrase, 'BURN_FILE': i.um_burn_file, @@ -4792,8 +4798,12 @@ def create_app(): mode='override', value=authorized_peer(hblink_req['login_id'])[1] ) - active_tgs[hblink_req['login_server']][hblink_req['system']] = [{'1':[]}, {'2':[]}, {'SYSTEM': ''}, {'peer_id':hblink_req['login_id']}] - print(active_tgs) + try: + active_tgs[hblink_req['login_server']][hblink_req['system']] = [{'1':[]}, {'2':[]}, {'SYSTEM': ''}, {'peer_id':hblink_req['login_id']}] +## print('Restart ' + hblink_req['login_server'] + ' please.') + except: + active_tgs[hblink_req['login_server']] = {} + pass elif authorized_peer(hblink_req['login_id'])[0] == False: ## print('log fail') authlog_add(hblink_req['login_id'], hblink_req['login_ip'], hblink_req['login_server'], 'Not Registered', '-', 'Failed')