misc clean up
This commit is contained in:
parent
e784c033e1
commit
d8b2d94cef
57
bridge.py
57
bridge.py
|
|
@ -89,30 +89,30 @@ __email__ = 'kf7eel@qsl.net'
|
||||||
|
|
||||||
##import os, ast
|
##import os, ast
|
||||||
|
|
||||||
# Function to download rules
|
### Function to download rules
|
||||||
def update_tg(CONFIG, mode, dmr_id, data):
|
##def update_tg(CONFIG, mode, dmr_id, data):
|
||||||
user_man_url = CONFIG['WEB_SERVICE']['URL']
|
## user_man_url = CONFIG['WEB_SERVICE']['URL']
|
||||||
shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
## shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||||
update_srv = {
|
## update_srv = {
|
||||||
'update_tg':CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'],
|
## 'update_tg':CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'],
|
||||||
'secret':shared_secret,
|
## 'secret':shared_secret,
|
||||||
'dmr_id': dmr_id,
|
## 'dmr_id': dmr_id,
|
||||||
## 'ts1': data['ts1'],
|
#### 'ts1': data['ts1'],
|
||||||
## 'ts2': data['ts2'],
|
#### 'ts2': data['ts2'],
|
||||||
'mode': mode,
|
## 'mode': mode,
|
||||||
'data': data
|
## 'data': data
|
||||||
}
|
## }
|
||||||
## print(rules_check)
|
#### print(rules_check)
|
||||||
json_object = json.dumps(update_srv, indent = 4)
|
## json_object = json.dumps(update_srv, indent = 4)
|
||||||
|
##
|
||||||
try:
|
## try:
|
||||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
## req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||||
## resp = json.loads(req.text)
|
#### resp = json.loads(req.text)
|
||||||
## print(resp)
|
#### print(resp)
|
||||||
## return resp['rules']
|
#### return resp['rules']
|
||||||
except requests.ConnectionError:
|
## except requests.ConnectionError:
|
||||||
logger.error('Config server unreachable, defaulting to local config')
|
## logger.error('Config server unreachable, defaulting to local config')
|
||||||
## return config.build_config(cli_file)
|
#### return config.build_config(cli_file)
|
||||||
|
|
||||||
|
|
||||||
def send_unit_table(CONFIG, _data):
|
def send_unit_table(CONFIG, _data):
|
||||||
|
|
@ -377,7 +377,7 @@ def hotspot_proxy(listen_port, port_start, port_stop):
|
||||||
reactor.listenUDP(ListenPort,Proxy(Master,ListenPort,CONNTRACK,BlackList,Timeout,Debug,ClientInfo,DestportStart,DestPortEnd),interface=ListenIP)
|
reactor.listenUDP(ListenPort,Proxy(Master,ListenPort,CONNTRACK,BlackList,Timeout,Debug,ClientInfo,DestportStart,DestPortEnd),interface=ListenIP)
|
||||||
|
|
||||||
def loopingErrHandle(failure):
|
def loopingErrHandle(failure):
|
||||||
print('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error innowtimed loop.\n {}'.format(failure))
|
logger.info('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error innowtimed loop.\n {}'.format(failure))
|
||||||
reactor.stop()
|
reactor.stop()
|
||||||
|
|
||||||
def stats():
|
def stats():
|
||||||
|
|
@ -390,7 +390,7 @@ def hotspot_proxy(listen_port, port_start, port_stop):
|
||||||
totalPorts = DestPortEnd - DestportStart
|
totalPorts = DestPortEnd - DestportStart
|
||||||
freePorts = totalPorts - count
|
freePorts = totalPorts - count
|
||||||
|
|
||||||
print("{} ports out of {} in use ({} free)".format(count,totalPorts,freePorts))
|
logger.info("{} ports out of {} in use ({} free)".format(count,totalPorts,freePorts))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -585,7 +585,6 @@ def rule_timer_loop(unit_flood_time):
|
||||||
|
|
||||||
# run this every 10 seconds to trim orphaned stream ids
|
# run this every 10 seconds to trim orphaned stream ids
|
||||||
def stream_trimmer_loop():
|
def stream_trimmer_loop():
|
||||||
print(UNIT_MAP)
|
|
||||||
ping(CONFIG)
|
ping(CONFIG)
|
||||||
logger.debug('(ROUTER) Trimming inactive stream IDs from system lists')
|
logger.debug('(ROUTER) Trimming inactive stream IDs from system lists')
|
||||||
_now = time()
|
_now = time()
|
||||||
|
|
@ -851,8 +850,8 @@ class routerOBP(OPENBRIDGE):
|
||||||
dmrpkt = _data[20:53]
|
dmrpkt = _data[20:53]
|
||||||
_bits = _data[15]
|
_bits = _data[15]
|
||||||
|
|
||||||
print('Src: ' + str(int_id(_rf_src)))
|
logger.debug('Src: ' + str(int_id(_rf_src)))
|
||||||
print('Dst: ' + str(int_id(_dst_id)))
|
logger.debug('Dst: ' + str(int_id(_dst_id)))
|
||||||
|
|
||||||
# Make/update this unit in the UNIT_MAP cache
|
# Make/update this unit in the UNIT_MAP cache
|
||||||
UNIT_MAP[_rf_src] = (self.name, pkt_time)
|
UNIT_MAP[_rf_src] = (self.name, pkt_time)
|
||||||
|
|
|
||||||
|
|
@ -991,9 +991,9 @@ def create_sms_seq(dst_id, src_id, peer_id, _slot, _call_type, dmr_string):
|
||||||
mmdvm_send_seq.append(the_mmdvm_pkt)
|
mmdvm_send_seq.append(the_mmdvm_pkt)
|
||||||
cap_in = cap_in + 1
|
cap_in = cap_in + 1
|
||||||
|
|
||||||
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == False:
|
## if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == False:
|
||||||
with open('/tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/' + str(random.randint(1000, 9999)) + '.mmdvm_seq', "w") as packet_write_file:
|
## with open('/tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/' + str(random.randint(1000, 9999)) + '.mmdvm_seq', "w") as packet_write_file:
|
||||||
packet_write_file.write(str(mmdvm_send_seq))
|
## packet_write_file.write(str(mmdvm_send_seq))
|
||||||
|
|
||||||
return mmdvm_send_seq
|
return mmdvm_send_seq
|
||||||
## return the_mmdvm_pkt
|
## return the_mmdvm_pkt
|
||||||
|
|
@ -1539,8 +1539,8 @@ def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _fr
|
||||||
float(loc.lon)
|
float(loc.lon)
|
||||||
## if int_id(_dst_id) == data_id:
|
## if int_id(_dst_id) == data_id:
|
||||||
if int_id(_dst_id) in data_id:
|
if int_id(_dst_id) in data_id:
|
||||||
aprs_send(aprs_loc_packet)
|
|
||||||
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, str(loc.lat[0:7]) + str(loc.lat_dir), str(loc.lon[0:8]) + str(loc.lon_dir), time(), comment, int_id(_rf_src))
|
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, str(loc.lat[0:7]) + str(loc.lat_dir), str(loc.lon[0:8]) + str(loc.lon_dir), time(), comment, int_id(_rf_src))
|
||||||
|
aprs_send(aprs_loc_packet)
|
||||||
except Exception as error_exception:
|
except Exception as error_exception:
|
||||||
logger.error('Failed to parse packet. Packet may be deformed. Not uploaded.')
|
logger.error('Failed to parse packet. Packet may be deformed. Not uploaded.')
|
||||||
logger.error(error_exception)
|
logger.error(error_exception)
|
||||||
|
|
@ -1665,46 +1665,46 @@ class OBP(OPENBRIDGE):
|
||||||
logger.debug('SVRD RCV')
|
logger.debug('SVRD RCV')
|
||||||
if _mode == b'UNIT':
|
if _mode == b'UNIT':
|
||||||
UNIT_MAP[_data] = (self._system, time())
|
UNIT_MAP[_data] = (self._system, time())
|
||||||
## if _mode == b'DATA' or _mode == b'MDAT':
|
if _mode == b'DATA' or _mode == b'MDAT':
|
||||||
#### print(ahex(_data))
|
## print(ahex(_data))
|
||||||
## # DMR Data packet, sent via SVRD
|
# DMR Data packet, sent via SVRD
|
||||||
## _peer_id = _data[11:15]
|
_peer_id = _data[11:15]
|
||||||
## _seq = _data[4]
|
_seq = _data[4]
|
||||||
## _rf_src = _data[5:8]
|
_rf_src = _data[5:8]
|
||||||
## _dst_id = _data[8:11]
|
_dst_id = _data[8:11]
|
||||||
## _bits = _data[15]
|
_bits = _data[15]
|
||||||
## _slot = 2 if (_bits & 0x80) else 1
|
_slot = 2 if (_bits & 0x80) else 1
|
||||||
## #_call_type = 'unit' if (_bits & 0x40) else 'group'
|
#_call_type = 'unit' if (_bits & 0x40) else 'group'
|
||||||
## if _bits & 0x40:
|
if _bits & 0x40:
|
||||||
## _call_type = 'unit'
|
_call_type = 'unit'
|
||||||
## elif (_bits & 0x23) == 0x23:
|
elif (_bits & 0x23) == 0x23:
|
||||||
## _call_type = 'vcsbk'
|
_call_type = 'vcsbk'
|
||||||
## else:
|
else:
|
||||||
## _call_type = 'group'
|
_call_type = 'group'
|
||||||
## _frame_type = (_bits & 0x30) >> 4
|
_frame_type = (_bits & 0x30) >> 4
|
||||||
## _dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F
|
_dtype_vseq = (_bits & 0xF) # data, 1=voice header, 2=voice terminator; voice, 0=burst A ... 5=burst F
|
||||||
## _stream_id = _data[16:20]
|
_stream_id = _data[16:20]
|
||||||
##
|
|
||||||
#### print(int_id(_peer_id))
|
## print(int_id(_peer_id))
|
||||||
#### print(int_id(_rf_src))
|
## print(int_id(_rf_src))
|
||||||
#### print(int_id(_dst_id))
|
## print(int_id(_dst_id))
|
||||||
#### print((_dtype_vseq))
|
## print((_dtype_vseq))
|
||||||
#### print(ahex(bptc_decode(_data)))
|
## print(ahex(bptc_decode(_data)))
|
||||||
##
|
|
||||||
## if _mode == b'MDAT' or _mode == b'DATA':
|
if _mode == b'MDAT' or _mode == b'DATA':
|
||||||
## print('MDAT')
|
print('MDAT')
|
||||||
## if _rf_src not in PACKET_MATCH:
|
if _rf_src not in PACKET_MATCH:
|
||||||
## PACKET_MATCH[_rf_src] = [_seq, time()]
|
PACKET_MATCH[_rf_src] = [_seq, time()]
|
||||||
## if _seq == PACKET_MATCH[_rf_src][0] and time() - 1 < PACKET_MATCH[_rf_src][1]:
|
if _seq == PACKET_MATCH[_rf_src][0] and time() - 1 < PACKET_MATCH[_rf_src][1]:
|
||||||
## print('matched, dropping')
|
print('matched, dropping')
|
||||||
## pass
|
pass
|
||||||
##
|
|
||||||
## else:
|
else:
|
||||||
## print('no match')
|
print('no match')
|
||||||
## if _mode == b'MDAT':
|
if _mode == b'MDAT':
|
||||||
## data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data, True)
|
data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data, True)
|
||||||
## if _mode == b'DATA':
|
if _mode == b'DATA':
|
||||||
## data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1791,7 +1791,6 @@ if __name__ == '__main__':
|
||||||
#### use_api = CONFIG['DATA_CONFIG']['USE_API']
|
#### use_api = CONFIG['DATA_CONFIG']['USE_API']
|
||||||
|
|
||||||
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
|
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
|
||||||
#### if 'DUAL_DASH' in CONFIG['WEB_SERVICE']['']
|
|
||||||
pass
|
pass
|
||||||
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == False:
|
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == False:
|
||||||
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
|
||||||
|
|
@ -1858,7 +1857,7 @@ if __name__ == '__main__':
|
||||||
ten_loop.addErrback(loopingErrHandle)
|
ten_loop.addErrback(loopingErrHandle)
|
||||||
|
|
||||||
if 'N0CALL' in aprs_callsign:
|
if 'N0CALL' in aprs_callsign:
|
||||||
logger.info('APRS callsighn set to N0CALL, packet not sent.')
|
logger.info('APRS callsign set to N0CALL, packet not sent.')
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
aprs_thread = threading.Thread(target=aprs_rx, args=(aprs_callsign, aprs_passcode, aprs_server, aprs_port, aprs_filter, user_ssid,))
|
aprs_thread = threading.Thread(target=aprs_rx, args=(aprs_callsign, aprs_passcode, aprs_server, aprs_port, aprs_filter, user_ssid,))
|
||||||
|
|
|
||||||
13
hblink.py
13
hblink.py
|
|
@ -325,7 +325,7 @@ class HBSYSTEM(DatagramProtocol):
|
||||||
try:
|
try:
|
||||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||||
resp = json.loads(req.text)
|
resp = json.loads(req.text)
|
||||||
print(resp)
|
logger.debug(resp)
|
||||||
return resp
|
return resp
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
return {'allow':True}
|
return {'allow':True}
|
||||||
|
|
@ -369,11 +369,9 @@ class HBSYSTEM(DatagramProtocol):
|
||||||
'software': re.sub("b'|'|\s\s+", '', str(soft))
|
'software': re.sub("b'|'|\s\s+", '', str(soft))
|
||||||
}
|
}
|
||||||
json_object = json.dumps(peer_loc_conf, indent = 4)
|
json_object = json.dumps(peer_loc_conf, indent = 4)
|
||||||
print()
|
|
||||||
print()
|
logger.debug(json_object)
|
||||||
print(json_object)
|
|
||||||
print()
|
|
||||||
print()
|
|
||||||
try:
|
try:
|
||||||
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'})
|
||||||
# resp = json.loads(req.text)
|
# resp = json.loads(req.text)
|
||||||
|
|
@ -625,13 +623,12 @@ class HBSYSTEM(DatagramProtocol):
|
||||||
else:
|
else:
|
||||||
user_auth = False
|
user_auth = False
|
||||||
elif self._config['USE_USER_MAN'] == False:
|
elif self._config['USE_USER_MAN'] == False:
|
||||||
print('False')
|
logger.debug('False, not using user manager')
|
||||||
b_acl = self._config['REG_ACL']
|
b_acl = self._config['REG_ACL']
|
||||||
if self._CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
|
if self._CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
|
||||||
# If UMS is False, and Rmote Confir True
|
# If UMS is False, and Rmote Confir True
|
||||||
if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']):
|
if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']):
|
||||||
user_auth = True
|
user_auth = True
|
||||||
print(self._CONFIG['GLOBAL']['REG_ACL'])
|
|
||||||
else:
|
else:
|
||||||
user_auth = False
|
user_auth = False
|
||||||
#If UMS and Remot Config False
|
#If UMS and Remot Config False
|
||||||
|
|
|
||||||
|
|
@ -7007,7 +7007,7 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
||||||
'''
|
'''
|
||||||
b_list = b_list + '''</tbody></table>
|
b_list = b_list + '''</tbody></table>
|
||||||
<h3 style="text-align: center;">View/Edit Rules (Bridges)</h3>
|
<h3 style="text-align: center;">View/Edit Rules (Bridges)</h3>
|
||||||
/
|
|
||||||
'''
|
'''
|
||||||
r_list = ''
|
r_list = ''
|
||||||
for i in s:
|
for i in s:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue