fix issue with hblink.py

This commit is contained in:
KF7EEL 2021-05-10 13:02:53 -07:00
parent 6ddfb2b1c1
commit 2159d09525

View File

@ -432,6 +432,9 @@ class HBSYSTEM(DatagramProtocol):
if len(self._peers) < self._config['MAX_PEERS']: if len(self._peers) < self._config['MAX_PEERS']:
# Check for valid Radio ID # Check for valid Radio ID
#print(self.check_user_man(_peer_id)) #print(self.check_user_man(_peer_id))
print('---')
print(self._config)
print('---')
if self._config['USE_USER_MAN'] == True: if self._config['USE_USER_MAN'] == True:
self.ums_response = self.check_user_man(_peer_id) self.ums_response = self.check_user_man(_peer_id)
## print(self.ums_response) ## print(self.ums_response)
@ -441,6 +444,7 @@ class HBSYSTEM(DatagramProtocol):
user_auth = False user_auth = False
print(user_auth) print(user_auth)
if self._config['USE_USER_MAN'] == False: if self._config['USE_USER_MAN'] == False:
print('Falsae')
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
if user_auth == True: if user_auth == True:
@ -491,25 +495,28 @@ class HBSYSTEM(DatagramProtocol):
_this_peer['LAST_PING'] = time() _this_peer['LAST_PING'] = time()
_sent_hash = _data[8:] _sent_hash = _data[8:]
_salt_str = bytes_4(_this_peer['SALT']) _salt_str = bytes_4(_this_peer['SALT'])
print(self.ums_response) #print(self.ums_response)
try: if self._config['USE_USER_MAN'] == True:
if self.ums_response['mode'] == 'legacy': try:
_calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest()) if self.ums_response['mode'] == 'legacy':
if self.ums_response['mode'] == 'override': _calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
_calc_hash = bhex(sha256(_salt_str+str.encode(self.ums_response['value'])).hexdigest()) if self.ums_response['mode'] == 'override':
if self.ums_response['mode'] == 'normal': _calc_hash = bhex(sha256(_salt_str+str.encode(self.ums_response['value'])).hexdigest())
_new_peer_id = bytes_4(int(str(int_id(_peer_id))[:7])) if self.ums_response['mode'] == 'normal':
## print(int_id(_new_peer_id)) _new_peer_id = bytes_4(int(str(int_id(_peer_id))[:7]))
calc_passphrase = base64.b64encode((_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big')) ## print(int_id(_new_peer_id))
print(calc_passphrase) calc_passphrase = base64.b64encode((_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))
print(calc_passphrase)
_calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
ums_down = False
except Exception as e:
## # If UMS down, default to base 64 auth
## logger.info(e)
calc_passphrase = base64.b64encode((_peer_id) + int(1).to_bytes(2, 'big'))
_calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest()) _calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
ums_down = False ums_down = True
except Exception as e: if self._config['USE_USER_MAN'] == False:
## # If UMS down, default to base 64 auth _calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
## logger.info(e)
calc_passphrase = base64.b64encode((_peer_id) + int(1).to_bytes(2, 'big'))
_calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
ums_down = True
if _sent_hash == _calc_hash or (ums_down == True and _sent_hash == _calc_hash): if _sent_hash == _calc_hash or (ums_down == True and _sent_hash == _calc_hash):
_this_peer['CONNECTION'] = 'WAITING_CONFIG' _this_peer['CONNECTION'] = 'WAITING_CONFIG'
self.send_peer(_peer_id, b''.join([RPTACK, _peer_id])) self.send_peer(_peer_id, b''.join([RPTACK, _peer_id]))