improve PROXY, other changes

This commit is contained in:
KF7EEL 2021-06-15 15:32:40 -07:00
parent e128e10dcc
commit 9980d65f57
5 changed files with 44 additions and 31 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

View File

@ -141,17 +141,17 @@ def download_config(L_CONFIG_FILE, cli_file):
## print((iterate_config['test']))
## print(corrected_config)
corrected_config['GLOBAL']['TG1_ACL'] = config.acl_build(corrected_config['GLOBAL']['TG1_ACL'], 16776415)
corrected_config['GLOBAL']['TG2_ACL'] = config.acl_build(corrected_config['GLOBAL']['TG2_ACL'], 16776415)
corrected_config['GLOBAL']['REG_ACL'] = config.acl_build(corrected_config['GLOBAL']['REG_ACL'], 16776415)
corrected_config['GLOBAL']['SUB_ACL'] = config.acl_build(corrected_config['GLOBAL']['SUB_ACL'], 16776415)
corrected_config['GLOBAL']['TG1_ACL'] = config.acl_build(corrected_config['GLOBAL']['TG1_ACL'], 4294967295)
corrected_config['GLOBAL']['TG2_ACL'] = config.acl_build(corrected_config['GLOBAL']['TG2_ACL'], 4294967295)
corrected_config['GLOBAL']['REG_ACL'] = config.acl_build(corrected_config['GLOBAL']['REG_ACL'], 4294967295)
corrected_config['GLOBAL']['SUB_ACL'] = config.acl_build(corrected_config['GLOBAL']['SUB_ACL'], 4294967295)
## corrected_config['SYSTEMS'] = {}
for i in iterate_config:
## print(i)
## corrected_config['SYSTEMS'][i] = {}
if iterate_config[i]['MODE'] == 'MASTER' or iterate_config[i]['MODE'] == 'PROXY':
corrected_config['SYSTEMS'][i]['TG1_ACL'] = config.acl_build(iterate_config[i]['TG1_ACL'], 16776415)
corrected_config['SYSTEMS'][i]['TG2_ACL'] = config.acl_build(iterate_config[i]['TG2_ACL'], 16776415)
corrected_config['SYSTEMS'][i]['TG1_ACL'] = config.acl_build(iterate_config[i]['TG1_ACL'], 4294967295)
corrected_config['SYSTEMS'][i]['TG2_ACL'] = config.acl_build(iterate_config[i]['TG2_ACL'], 4294967295)
corrected_config['SYSTEMS'][i]['PASSPHRASE'] = bytes(iterate_config[i]['PASSPHRASE'], 'utf-8')
if iterate_config[i]['MODE'] == 'OPENBRIDGE':
corrected_config['SYSTEMS'][i]['NETWORK_ID'] = int(iterate_config[i]['NETWORK_ID']).to_bytes(4, 'big')
@ -159,8 +159,8 @@ def download_config(L_CONFIG_FILE, cli_file):
if iterate_config[i]['MODE'] == 'PEER' or iterate_config[i]['MODE'] == 'XLXPEER':
corrected_config['SYSTEMS'][i]['RADIO_ID'] = int(iterate_config[i]['RADIO_ID']).to_bytes(4, 'big')
corrected_config['SYSTEMS'][i]['TG1_ACL'] = config.acl_build(iterate_config[i]['TG1_ACL'], 16776415)
corrected_config['SYSTEMS'][i]['TG2_ACL'] = config.acl_build(iterate_config[i]['TG2_ACL'], 16776415)
corrected_config['SYSTEMS'][i]['TG1_ACL'] = config.acl_build(iterate_config[i]['TG1_ACL'], 4294967295)
corrected_config['SYSTEMS'][i]['TG2_ACL'] = config.acl_build(iterate_config[i]['TG2_ACL'], 4294967295)
corrected_config['SYSTEMS'][i]['MASTER_SOCKADDR'] = tuple(iterate_config[i]['MASTER_SOCKADDR'])
corrected_config['SYSTEMS'][i]['SOCK_ADDR'] = tuple(iterate_config[i]['SOCK_ADDR'])
corrected_config['SYSTEMS'][i]['PASSPHRASE'] = bytes((iterate_config[i]['PASSPHRASE']), 'utf-8')

View File

@ -258,7 +258,7 @@ class HBSYSTEM(DatagramProtocol):
#Change this to a config value
user_man_url = self._CONFIG['USER_MANAGER']['URL']
shared_secret = str(sha256(self._CONFIG['USER_MANAGER']['SHARED_SECRET'].encode()).hexdigest())
#print(int(str(int_id(_id))[:7]))
## print(int(str(int_id(_id))[:7]))
auth_check = {
'secret':shared_secret,
'login_id':int(str(int_id(_id))[:7]),
@ -269,6 +269,7 @@ class HBSYSTEM(DatagramProtocol):
try:
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
resp = json.loads(req.text)
## print(resp)
return resp
except requests.ConnectionError:
return {'allow':True}
@ -517,6 +518,7 @@ class HBSYSTEM(DatagramProtocol):
# Check for valid Radio ID
#print(self.check_user_man(_peer_id))
if self._config['USE_USER_MAN'] == True:
## print(str(_peer_id) + ' - hblink.py')
self.ums_response = self.check_user_man(_peer_id, self._CONFIG['USER_MANAGER']['THIS_SERVER_NAME'], _sockaddr[0])
## print(self.ums_response)
#Will allow anyone to attempt authentication, used for a transition period

View File

@ -66,21 +66,30 @@ class Proxy(DatagramProtocol):
#If the packet comes from the master
if host == self.master:
_command = data[:4]
_lng_command = data[:6]
#### print(_lng_command)
if _command == DMRD:
_peer_id = data[11:15]
## print(self.peerTrack[_peer_id]['timer'])
elif _command == RPTA:
if data[6:10] in self.peerTrack:
_peer_id = data[6:10]
else:
_peer_id = self.connTrack[port]
elif _command == MSTN:
elif _lng_command == MSTNAK:
_peer_id = data[6:10]
elif _command == MSTN and MSTNAK not in _lng_command:
_peer_id = data[6:10]
self.peerTrack[_peer_id]['timer'].cancel()
self.reaper(_peer_id)
return
elif _command == MSTP:
_peer_id = data[7:11]
## print(self.peerTrack)
elif _command == MSTC:
_peer_id = data[5:9]
self.peerTrack[_peer_id]['timer'].cancel()
@ -150,6 +159,7 @@ class Proxy(DatagramProtocol):
self.transport.write(data, (self.master,_dport))
if self.debug:
print(data)
return

View File

@ -461,10 +461,10 @@ def create_app():
_new_peer_id = bytes_4(int(str(dmr_id)[:7]))
trimmed_id = int(str(dmr_id)[:7])
b_list = get_burnlist()
print(b_list)
# print(b_list)
burned = False
for ui in b_list.items():
print(ui)
# print(ui)
#print(b_list)
if ui[0] == trimmed_id:
if ui[0] != 0:
@ -1719,6 +1719,7 @@ def create_app():
p = mmdvmPeer.query.filter_by(server=_server).filter_by(name=_name).first()
if _mode == 'xlx':
p = xlxPeer.query.filter_by(server=_server).filter_by(name=_name).first()
db.session.delete(p)
db.session.commit()
@ -1901,16 +1902,16 @@ def create_app():
print(s_config['REPORTS'])
return s_config
def masters_get(_name):
## print(_name)
## # print(_name)
#s = ServerList.query.filter_by(name=_name).first()
# print(s.name)
i = MasterList.query.filter_by(server=_name).filter_by(active=True).all()
o = OBP.query.filter_by(server=_name).filter_by(enabled=True).all()
p = ProxyList.query.filter_by(server=_name).filter_by(active=True).all()
print('get masters')
# print('get masters')
master_config_list = {}
## master_config_list['SYSTEMS'] = {}
print(i)
# print(i)
for m in i:
print (m.name)
master_config_list.update({m.name: {
@ -1970,7 +1971,7 @@ def create_app():
}})
master_config_list[pr.name].update({'PEERS': {}})
print(master_config_list)
# print(master_config_list)
return master_config_list
def add_system_rule(_bridge_name, _system_name, _ts, _tg, _active, _timeout, _to_type, _on, _off, _reset, _server, _public_list):
@ -2013,7 +2014,7 @@ def create_app():
def server_edit(_name, _secret, _ip, _public_list, _port, _global_path, _global_ping_time, _global_max_missed, _global_use_acl, _global_reg_acl, _global_sub_acl, _global_tg1_acl, _global_tg2_acl, _ai_subscriber_file, _ai_try_download, _ai_path, _ai_peer_file, _ai_tgid_file, _ai_peer_url, _ai_subs_url, _ai_stale, _um_shorten_passphrase, _um_burn_file, _report_enable, _report_interval, _report_port, _report_clients, _unit_time, _notes):
s = ServerList.query.filter_by(name=_name).first()
print(_name)
# print(_name)
if _secret == '':
s.secret = s.secret
else:
@ -2088,7 +2089,7 @@ def create_app():
m.notes = _notes
db.session.commit()
if _mode == 'OBP':
print(_enable_unit)
# print(_enable_unit)
## print(enable_unit)
o = OBP.query.filter_by(server=_server).filter_by(name=_name).first()
o.enabled = _active
@ -2153,7 +2154,7 @@ def create_app():
## db.session.add(add_master)
def add_master(_mode, _name, _server, _static_positions, _repeat, _active, _max_peers, _ip, _port, _enable_um, _passphrase, _group_hang_time, _use_acl, _reg_acl, _sub_acl, _tg1_acl, _tg2_acl, _enable_unit, _notes, _external_proxy, _int_start_port, _int_stop_port, _network_id, _target_ip, _target_port, _both_slots):
print(_mode)
# print(_mode)
if _mode == 'MASTER':
add_master = MasterList(
name = _name,
@ -2202,8 +2203,8 @@ def create_app():
db.session.add(add_proxy)
db.session.commit()
if _mode == 'OBP':
print(_name)
print(_network_id)
# print(_name)
# print(_network_id)
add_OBP = OBP(
name = _name,
enabled = _active,
@ -2380,7 +2381,7 @@ def create_app():
## s = mmdvmPeer.query.filter_by(server=_server).filter_by(name=_name).first()
p = xlxPeer.query.filter_by(server=_server).filter_by(name=_name).first()
print(type(p.enable_unit))
# print(type(p.enable_unit))
p.enabled = _enabled
p.loose = _loose
p.ip = _ip
@ -3318,7 +3319,7 @@ def create_app():
all_s = ServerList.query.all()
p_list = ''
for s in all_s:
print(s.name)
# print(s.name)
p_list = p_list + '''
<h4 style="text-align: center;">Server: ''' + str(s.name) + '''</h4>
<table style="width: 400px; margin-left: auto; margin-right: auto;" border="1">
@ -3573,8 +3574,8 @@ def create_app():
'''
elif request.args.get('edit_proxy'):
print(request.args.get('server'))
print(request.args.get('edit_proxy'))
# print(request.args.get('server'))
# print(request.args.get('edit_proxy'))
p = ProxyList.query.filter_by(server=request.args.get('server')).filter_by(name=request.args.get('edit_proxy')).first()
content = '''
<p>&nbsp;</p>
@ -4307,8 +4308,8 @@ def create_app():
elif request.args.get('save_rule') == 'edit':
content = 'edit rule'
elif request.args.get('save_rule') == 'delete':
print(request.args.get('bridge'))
print(request.args.get('server'))
# print(request.args.get('bridge'))
# print(request.args.get('server'))
if request.args.get('system'):
delete_system_rule(request.args.get('bridge'), request.args.get('server'), request.args.get('system'))
else:
@ -4578,7 +4579,7 @@ def create_app():
'''
r_list = ''
for i in s:
print(i)
# print(i)
r_list = r_list + '''
<table style="width: 500px; margin-left: auto; margin-right: auto;" border="1">
<tbody>
@ -4616,7 +4617,7 @@ def create_app():
@app.route('/svr', methods=['POST'])
def auth():
hblink_req = request.json
print((hblink_req))
# print((hblink_req))
if hblink_req['secret'] in shared_secrets():
if 'login_id' in hblink_req and 'login_confirmed' not in hblink_req:
if type(hblink_req['login_id']) == int:
@ -4635,14 +4636,14 @@ def create_app():
)
elif authorized_peer(hblink_req['login_id'])[1] != '' or isinstance(authorized_peer(hblink_req['login_id'])[1], int) == False:
authlog_add(hblink_req['login_id'], hblink_req['login_ip'], hblink_req['login_server'], authorized_peer(hblink_req['login_id'])[2], authorized_peer(hblink_req['login_id'])[1], 'Attempt')
print(authorized_peer(hblink_req['login_id']))
# print(authorized_peer(hblink_req['login_id']))
response = jsonify(
allow=True,
mode='override',
value=authorized_peer(hblink_req['login_id'])[1]
)
elif authorized_peer(hblink_req['login_id'])[0] == False:
print('log fail')
## print('log fail')
authlog_add(hblink_req['login_id'], hblink_req['login_ip'], hblink_req['login_server'], 'Not Registered', '-', 'Failed')
response = jsonify(
allow=False)