add legacy override

This commit is contained in:
KF7EEL 2021-05-26 11:06:12 -07:00
parent a03a9e1018
commit 92e0e2e405
1 changed files with 9 additions and 5 deletions

View File

@ -240,7 +240,7 @@ class HBSYSTEM(DatagramProtocol):
#Change this to a config value
user_man_url = self._CONFIG['USER_MANAGER']['URL']
shared_secret = self._CONFIG['USER_MANAGER']['SHARED_SECRET']
print(int(str(int_id(_id))[:7]))
#print(int(str(int_id(_id))[:7]))
auth_check = {
'id':int(str(int_id(_id))[:7]),
'secret':shared_secret
@ -493,6 +493,9 @@ class HBSYSTEM(DatagramProtocol):
_this_peer['LAST_PING'] = time()
_sent_hash = _data[8:]
_salt_str = bytes_4(_this_peer['SALT'])
# Used to allow config passphrase AND calculated.
_ocalc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
#print(self.ums_response)
if self._config['USE_USER_MAN'] == True:
## print(self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'])
@ -503,7 +506,6 @@ class HBSYSTEM(DatagramProtocol):
_calc_hash = bhex(sha256(_salt_str+str.encode(self.ums_response['value'])).hexdigest())
if self.ums_response['mode'] == 'normal':
_new_peer_id = bytes_4(int(str(int_id(_peer_id))[:7]))
## print(int_id(_new_peer_id))
#print(self._CONFIG['USER_MANAGER']['APPEND_INT'])
if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == True:
calc_passphrase = base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))
@ -514,8 +516,7 @@ class HBSYSTEM(DatagramProtocol):
_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)
## # If UMS down, default to base 64 auth
_new_peer_id = bytes_4(int(str(int_id(_peer_id))[:7]))
if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == True:
calc_passphrase = base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))
@ -526,7 +527,10 @@ class HBSYSTEM(DatagramProtocol):
ums_down = True
if self._config['USE_USER_MAN'] == False:
_calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
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):
if _sent_hash == _calc_hash or (ums_down == True and _sent_hash == _calc_hash) or (ums_down == False and _sent_hash == _ocalc_hash):
_this_peer['CONNECTION'] = 'WAITING_CONFIG'
self.send_peer(_peer_id, b''.join([RPTACK, _peer_id]))
logger.info('(%s) Peer %s has completed the login exchange successfully', self._system, _this_peer['RADIO_ID'])