diff --git a/bridge.py b/bridge.py index 96796e9..ba0f594 100755 --- a/bridge.py +++ b/bridge.py @@ -118,13 +118,14 @@ __email__ = 'kf7eel@qsl.net' #### return config.build_config(cli_file) -def send_unit_table(CONFIG, _data): +def send_unit_table(CONFIG, _data, _bridge_data): user_man_url = CONFIG['WEB_SERVICE']['URL'] shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest()) sms_data = { 'unit_table': CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'], 'secret':shared_secret, 'data': str(_data), + 'bridge_data': str(_bridge_data), } json_object = json.dumps(sms_data, indent = 4) @@ -592,7 +593,7 @@ def rule_timer_loop(unit_flood_time): for unit in remove_list: del UNIT_MAP[unit] - send_unit_table(CONFIG, UNIT_MAP) + send_unit_table(CONFIG, UNIT_MAP, BRIDGES) logger.debug('Removed unit(s) %s from UNIT_MAP', remove_list) diff --git a/web/app.py b/web/app.py index 41987b7..6635554 100644 --- a/web/app.py +++ b/web/app.py @@ -1158,6 +1158,37 @@ By using this service, you agree not to do anything malicious. You agree to use def gateway_wiz_page(add_server): return render_template('data_gateway_wizard.html', server = add_server) + @app.route('/bridge_status//') + def bridge_tg_status(server, system): + server_bridges = Misc.query.filter_by(field_1='bridge_table_' + server).first() + BRIDGES = ast.literal_eval(server_bridges.field_2) + table_data = '' + for _bridge in BRIDGES: + for e in BRIDGES[_bridge]: + if system == e['SYSTEM']: +## print(e) + print(type(e['TIMER'])) + print(datetime.datetime.fromtimestamp(e['TIMER'])) + print() + if time.time() <= e['TIMER']: + exp = ''' +
+ On
''' + str(datetime.datetime.fromtimestamp(e['TIMER'])).strftime(time_format) + ''' +
+''' + elif time.time() > e['TIMER']: + exp = ''' +
+ Off +
+''' + table_data = table_data + '' + _bridge + '' + str(int_id(e['TGID'])) + '' + exp + '' + +## print(str((timedelta(seconds=e['TIMER']) + datetime.datetime.fromtimestamp(e['TIMER'])).strftime(time_format))) + + + return render_template('bridge_status.html', table_data = Markup(table_data), server = server, system = system) + @app.route('/generate_passphrase/pi-star', methods = ['GET']) @login_required def gen_pi_star(): @@ -1235,6 +1266,17 @@ By using this service, you agree not to do anything malicious. You agree to use if i.ip == '': pass else: + tool_menu = ''' + +''' svr_content = svr_content + '''

''' + i.name + '''

@@ -1243,10 +1285,7 @@ By using this service, you agree not to do anything malicious. You agree to use ''' + svr_status + '''
''' + i.public_notes + '''

 

- -
- - +''' + tool_menu + '''
@@ -5312,7 +5351,6 @@ Name: ''' + p.name + '''  -  Port: ''' + str( ''' for s in all_s: tool_menu = ''' - - ''' try: if time.time() - ping_list[s.name] < 30: @@ -7660,9 +7697,12 @@ Name: ''' + p.name + '''  -  Port: ''' + str( try: delete_misc_field_1('unit_table_' + hblink_req['unit_table']) misc_add('unit_table_' + hblink_req['unit_table'], str(hblink_req['data']), '', '', 0, 0, 0, 0, False, False) + delete_misc_field_1('bridge_table_' + hblink_req['unit_table']) + misc_add('bridge_table_' + hblink_req['unit_table'], str(hblink_req['bridge_data']), '', '', 0, 0, 0, 0, False, False) except: print('entry error') misc_add('unit_table_' + hblink_req['unit_table'], str(hblink_req['data']), '', '', 0, 0, 0, 0, False, False) + misc_add('bridge_table_' + hblink_req['unit_table'], str(hblink_req['bridge_data']), '', '', 0, 0, 0, 0, False, False) ## unit_table_add(hblink_req['data']) response = 'rcvd' elif 'known_services' in hblink_req: