diff --git a/full_bridge-SAMPLE.cfg b/full_bridge-SAMPLE.cfg index 4b8bac5..e33c651 100644 --- a/full_bridge-SAMPLE.cfg +++ b/full_bridge-SAMPLE.cfg @@ -178,12 +178,11 @@ USER_SETTINGS_FILE: /path/to/user_settings.txt # Server name - can be different than dashboard title, used to identify this network/server USE_API: True AUTHORIZED_TOKENS_FILE: /tmp/hblink_auth_tokens.txt -AUTHORIZED_USERS_FILE: /path/to/authorized_users.txt -ACCESS_SYSTEMS_FILE: /path/to/access_systems.txt -MY_API_NAME: ABC +MY_SERVER_SHORTCUT: ABC SERVER_NAME: Test HBLink Network USE_PUBLIC_APPS: True PUBLIC_APPS_LIST: https://raw.githubusercontent.com/kf7eel/hblink_sms_external_apps/main/public_systems.txt +RULES_PATH: /path/to/rules.py # The following options are used for the dashboard. The dashboard is optional. diff --git a/full_bridge.py b/full_bridge.py index a61d4f0..462eb38 100644 --- a/full_bridge.py +++ b/full_bridge.py @@ -255,7 +255,7 @@ def send_app_request(url, message, source_id): auth_token.close() app_request = { 'mode':'app', - 'system_shortcut':CONFIG['GPS_DATA']['MY_API_NAME'], + 'system_shortcut':CONFIG['GPS_DATA']['MY_SERVER_SHORTCUT'], 'server_name':CONFIG['GPS_DATA']['SERVER_NAME'], 'response_url':CONFIG['GPS_DATA']['DASHBOARD_URL'] + '/api', 'auth_token':the_token, @@ -276,7 +276,7 @@ def send_msg_xfer(url, user, password, message, source_id, dest_id): url = url + '/api/msg_xfer' msg_xfer = { 'mode':'msg_xfer', - 'system_shortcut':CONFIG['GPS_DATA']['MY_API_NAME'], + 'system_shortcut':CONFIG['GPS_DATA']['MY_SERVER_SHORTCUT'], 'response_url':CONFIG['GPS_DATA']['DASHBOARD_URL'] + '/api', 'auth_type':'private', 'credentials': { @@ -724,7 +724,7 @@ def create_sms_seq(dst_id, src_id, peer_id, _slot, _call_type, dmr_string): the_mmdvm_pkt = mmdvm_encapsulate(dst_id, src_id, peer_id, cap_in, _slot, _call_type, 7, rand_seq, i)#(bytes.fromhex(re.sub("b'|'", '', str(orig_cap[cap_in][20:-4]))))) mmdvm_send_seq.append(ahex(the_mmdvm_pkt)) cap_in = cap_in + 1 - with open('/tmp/.hblink_data_que/' + str(random.randint(1000, 9999)) + '.mmdvm_seq', "w") as packet_write_file: + with open('/tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/' + str(random.randint(1000, 9999)) + '.mmdvm_seq', "w") as packet_write_file: packet_write_file.write(str(mmdvm_send_seq)) return mmdvm_send_seq @@ -827,9 +827,9 @@ def data_que_send(): #logger.info('Check SMS que') try: #logger.info(UNIT_MAP) - for packet_file in os.listdir('/tmp/.hblink_data_que/'): + for packet_file in os.listdir('/tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/'): - snd_seq = ast.literal_eval(os.popen('cat /tmp/.hblink_data_que/' + packet_file).read()) + snd_seq = ast.literal_eval(os.popen('cat /tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/' + packet_file).read()) for data in snd_seq: # Get dest id @@ -856,7 +856,7 @@ def data_que_send(): reactor.callFromThread(systems[data_target].send_system,bytes.fromhex(re.sub("b'|'", '', str(data)))) logger.info('Sending data to ' + str(data[10:16])[2:-1] + ' on system ' + data_target) - os.system('rm /tmp/.hblink_data_que/' + packet_file) + os.system('rm /tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/' + packet_file) #routerHBP.send_peer('MASTER-2', bytes.fromhex(re.sub("b'|'", '', str(data)))) ## os.system('rm /tmp/.hblink_data_que/' + packet_file) @@ -2331,7 +2331,7 @@ if __name__ == '__main__': mailbox_file.write("[]") mailbox_file.close() try: - Path('/tmp/.hblink_data_que/').mkdir(parents=True, exist_ok=True) + Path('/tmp/.hblink_data_que_' + str(CONFIG['GPS_DATA']['APRS_LOGIN_CALL']).upper() + '/').mkdir(parents=True, exist_ok=True) except: logger.info('Unable to create data que directory') pass diff --git a/rules_SAMPLE.py b/rules_SAMPLE.py index 3a7863f..0583213 100755 --- a/rules_SAMPLE.py +++ b/rules_SAMPLE.py @@ -80,11 +80,11 @@ authorized_users = { ## 'user':'test_name', ## 'password':'passw0rd' ## }, -## 'DEF':{ -## 'mode':'msg_xfer', -## 'user':'test_name', -## 'password':'passw0rd' -## } + 'XYZ':{ + 'mode':'msg_xfer', + 'user':'test_name', + 'password':'passw0rd' + } } local_systems = { diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index c6174b8..4125946 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -31,6 +31,8 @@ from datetime import datetime import argparse from configparser import ConfigParser from send_sms import * +import importlib.util +import requests @@ -199,6 +201,41 @@ def user_setting_write(dmr_id, input_ssid, input_icon, input_comment, input_aprs user_dict_file.close() + +def generate_apps(): + global access_systems, authorized_users + mod = importlib.util.spec_from_file_location("rules_data", parser.get('GPS_DATA', 'RULES_PATH')) + rules = importlib.util.module_from_spec(mod) + mod.loader.exec_module(rules) + local_apps = rules.local_apps + authorized_users = rules.authorized_users + + #rules_data = ast.literal_eval(os.popen('cat ' + parser.get('GPS_DATA', 'RULES_PATH')).read()) + #rules_data + public_systems_file = requests.get(parser.get('GPS_DATA', 'PUBLIC_APPS_LIST')) + public_apps = ast.literal_eval(public_systems_file.text) + access_systems = {} + #combined = public_apps.items() + local_acess_systems.items() + print(type(parser.get('GPS_DATA', 'USE_PUBLIC_APPS'))) + if parser.get('GPS_DATA', 'USE_PUBLIC_APPS') == 'True': + for i in public_apps.items(): + key = str(i[0]) + access_systems[key] = i[1] + for i in local_apps.items(): + key = str(i[0]) + access_systems[key] = i[1] + print(access_systems) + print(authorized_users) + print(local_apps) + #print(rules_data) + + #print(type(public_apps)) + #print(type(local_acess_systems)) + #print() + #print(combined) + #print(local_acess_systems.update(public_apps)) + #return access_systems + @app.route('/') def index(): value = Markup('The HTML String') @@ -223,7 +260,7 @@ def about(): @app.route('/external_apps') def external_apps(): - access_systems = ast.literal_eval(os.popen('cat ' + access_systems_file).read()) + #access_systems = ast.literal_eval(os.popen('cat ' + access_systems_file).read()) msg_lst = '' app_lst = '' for i_msg in access_systems.items(): @@ -793,8 +830,8 @@ def api(api_mode=None): api_content = '