change active_tg structure, improve passphrase security
This commit is contained in:
		
							parent
							
								
									b382ffa21f
								
							
						
					
					
						commit
						7db02fcb4b
					
				
							
								
								
									
										21
									
								
								bridge.py
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								bridge.py
									
									
									
									
									
								
							@ -380,11 +380,15 @@ def rule_timer_loop():
 | 
				
			|||||||
                        _system['ACTIVE'] = True
 | 
					                        _system['ACTIVE'] = True
 | 
				
			||||||
                        logger.info('(ROUTER) Conference Bridge TIMEOUT: ACTIVATE System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
 | 
					                        logger.info('(ROUTER) Conference Bridge TIMEOUT: ACTIVATE System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
 | 
				
			||||||
                        # POST ON
 | 
					                        # POST ON
 | 
				
			||||||
 | 
					##                        update_tg(CONFIG, 'on', 0, [{'SYSTEM':_system['SYSTEM']}, {'ts':_system['TS']}, {'tg': int_id(_system['TGID'])}])
 | 
				
			||||||
                    else:
 | 
					                    else:
 | 
				
			||||||
                        timeout_in = _system['TIMER'] - _now
 | 
					                        timeout_in = _system['TIMER'] - _now
 | 
				
			||||||
                        logger.info('(ROUTER) Conference Bridge INACTIVE (OFF timer running): System: %s Bridge: %s, TS: %s, TGID: %s, Timeout in: %.2fs,', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']),  timeout_in)
 | 
					                        logger.info('(ROUTER) Conference Bridge INACTIVE (OFF timer running): System: %s Bridge: %s, TS: %s, TGID: %s, Timeout in: %.2fs,', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']),  timeout_in)
 | 
				
			||||||
                elif _system['ACTIVE'] == True:
 | 
					                elif _system['ACTIVE'] == True:
 | 
				
			||||||
                    logger.debug('(ROUTER) Conference Bridge ACTIVE (no change): System: %s Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
 | 
					                    logger.debug('(ROUTER) Conference Bridge ACTIVE (no change): System: %s Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
 | 
				
			||||||
 | 
					                    # POST on
 | 
				
			||||||
 | 
					##                    print(_system)
 | 
				
			||||||
 | 
					##                    update_tg(CONFIG, 'on', 0, [{'SYSTEM':_system['SYSTEM']}, {'ts':_system['TS']}, {'tg': int_id(_system['TGID'])}])
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                logger.debug('(ROUTER) Conference Bridge NO ACTION: System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
 | 
					                logger.debug('(ROUTER) Conference Bridge NO ACTION: System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1095,15 +1099,9 @@ class routerHBP(HBSYSTEM):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                        # TGID matches an ACTIVATION trigger
 | 
					                        # TGID matches an ACTIVATION trigger
 | 
				
			||||||
                        if (_dst_id in _system['ON'] or _dst_id in _system['RESET']) and _slot == _system['TS']:
 | 
					                        if (_dst_id in _system['ON'] or _dst_id in _system['RESET']) and _slot == _system['TS']:
 | 
				
			||||||
                            # Insert POST for TG timer update?
 | 
					                            # POST update TG for self care
 | 
				
			||||||
                            print(self.STATUS[2])
 | 
					 | 
				
			||||||
                            print()
 | 
					 | 
				
			||||||
                            print(_system['SYSTEM'])
 | 
					 | 
				
			||||||
                            print()
 | 
					 | 
				
			||||||
                            print(datetime.fromtimestamp(_system['TIMER']).strftime('%H:%M:%S - %m/%d/%y'))
 | 
					 | 
				
			||||||
                            
 | 
					 | 
				
			||||||
##                            update_tg(CONFIG, 'on', int(str(int_id(self.STATUS[2]['RX_PEER']))[:7]), [{'SYSTEM':_system['SYSTEM']}, {'ts1':int_id(self.STATUS[i]['RX_TGID'])}, {'ts1':int_id(self.STATUS[2]['RX_TGID'])}])
 | 
					 | 
				
			||||||
                            update_tg(CONFIG, 'on', int(str(int_id(self.STATUS[2]['RX_PEER']))[:7]), [{'SYSTEM':_system['SYSTEM']}, {'ts1':int_id(self.STATUS[1]['RX_TGID'])}, {'ts2':int_id(self.STATUS[2]['RX_TGID'])}])
 | 
					                            update_tg(CONFIG, 'on', int(str(int_id(self.STATUS[2]['RX_PEER']))[:7]), [{'SYSTEM':_system['SYSTEM']}, {'ts1':int_id(self.STATUS[1]['RX_TGID'])}, {'ts2':int_id(self.STATUS[2]['RX_TGID'])}])
 | 
				
			||||||
 | 
					##                            print(datetime.fromtimestamp(_system['TIMER']).strftime('%H:%M:%S - %m/%d/%y'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
##                            update_tg(CONFIG, mode, dmr_id, data)
 | 
					##                            update_tg(CONFIG, mode, dmr_id, data)
 | 
				
			||||||
                            # Set the matching rule as ACTIVE
 | 
					                            # Set the matching rule as ACTIVE
 | 
				
			||||||
@ -1112,11 +1110,6 @@ class routerHBP(HBSYSTEM):
 | 
				
			|||||||
                                    _system['ACTIVE'] = True
 | 
					                                    _system['ACTIVE'] = True
 | 
				
			||||||
                                    _system['TIMER'] = pkt_time + _system['TIMEOUT']
 | 
					                                    _system['TIMER'] = pkt_time + _system['TIMEOUT']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
##                                    print()
 | 
					 | 
				
			||||||
##                                    print(int_id(self.STATUS[2]['RX_PEER']))
 | 
					 | 
				
			||||||
##                                    print()
 | 
					 | 
				
			||||||
                                    
 | 
					 | 
				
			||||||
                                    logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE'])
 | 
					                                    logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE'])
 | 
				
			||||||
                                    # Cancel the timer if we've enabled an "OFF" type timeout
 | 
					                                    # Cancel the timer if we've enabled an "OFF" type timeout
 | 
				
			||||||
                                    if _system['TO_TYPE'] == 'OFF':
 | 
					                                    if _system['TO_TYPE'] == 'OFF':
 | 
				
			||||||
@ -1136,7 +1129,7 @@ class routerHBP(HBSYSTEM):
 | 
				
			|||||||
                                    logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE'])
 | 
					                                    logger.info('(%s) Bridge: %s, connection changed to state: %s', self._system, _bridge, _system['ACTIVE'])
 | 
				
			||||||
                                    # POST off
 | 
					                                    # POST off
 | 
				
			||||||
                                    update_tg(CONFIG, 'off', 0, [{'SYSTEM':_system['SYSTEM']}, {'ts':_system['TS']}, {'tg': int_id(_system['TGID'])}])
 | 
					                                    update_tg(CONFIG, 'off', 0, [{'SYSTEM':_system['SYSTEM']}, {'ts':_system['TS']}, {'tg': int_id(_system['TGID'])}])
 | 
				
			||||||
                                    update_tg(CONFIG, 'on', int(str(int_id(self.STATUS[2]['RX_PEER']))[:7]), [{'SYSTEM':_system['SYSTEM']}, {'ts1':int_id(self.STATUS[1]['RX_TGID'])}, {'ts2':int_id(self.STATUS[2]['RX_TGID'])}])
 | 
					##                                    update_tg(CONFIG, 'on', int(str(int_id(self.STATUS[2]['RX_PEER']))[:7]), [{'SYSTEM':_system['SYSTEM']}, {'ts1':int_id(self.STATUS[1]['RX_TGID'])}, {'ts2':int_id(self.STATUS[2]['RX_TGID'])}])
 | 
				
			||||||
                                    # Cancel the timer if we've enabled an "ON" type timeout
 | 
					                                    # Cancel the timer if we've enabled an "ON" type timeout
 | 
				
			||||||
                                    if _system['TO_TYPE'] == 'ON':
 | 
					                                    if _system['TO_TYPE'] == 'ON':
 | 
				
			||||||
                                        _system['TIMER'] = pkt_time
 | 
					                                        _system['TIMER'] = pkt_time
 | 
				
			||||||
 | 
				
			|||||||
@ -160,8 +160,14 @@ def build_config(_config_file):
 | 
				
			|||||||
                    'URL': config.get(section, 'URL'),
 | 
					                    'URL': config.get(section, 'URL'),
 | 
				
			||||||
                    'REMOTE_CONFIG_ENABLED': config.getboolean(section, 'REMOTE_CONFIG_ENABLED'),
 | 
					                    'REMOTE_CONFIG_ENABLED': config.getboolean(section, 'REMOTE_CONFIG_ENABLED'),
 | 
				
			||||||
                    'APPEND_INT': config.getint(section, 'APPEND_INT'),
 | 
					                    'APPEND_INT': config.getint(section, 'APPEND_INT'),
 | 
				
			||||||
 | 
					                    'EXTRA_INT_1': config.getint(section, 'EXTRA_INT_1'),
 | 
				
			||||||
 | 
					                    'EXTRA_INT_2': config.getint(section, 'EXTRA_INT_2'),
 | 
				
			||||||
 | 
					                    'EXTRA_1': config.get(section, 'EXTRA_1'),
 | 
				
			||||||
 | 
					                    'EXTRA_2': config.get(section, 'EXTRA_2'),
 | 
				
			||||||
                    'SHARED_SECRET': config.get(section, 'SHARED_SECRET'),
 | 
					                    'SHARED_SECRET': config.get(section, 'SHARED_SECRET'),
 | 
				
			||||||
                    'SHORTEN_PASSPHRASE': config.getboolean(section, 'SHORTEN_PASSPHRASE'),
 | 
					                    'SHORTEN_PASSPHRASE': config.getboolean(section, 'SHORTEN_PASSPHRASE'),
 | 
				
			||||||
 | 
					                    'SHORTEN_SAMPLE': config.get(section, 'SHORTEN_SAMPLE'),
 | 
				
			||||||
 | 
					                    'SHORTEN_LENGTH': config.get(section, 'SHORTEN_LENGTH'),
 | 
				
			||||||
                    'BURN_FILE': config.get(section, 'BURN_FILE'),
 | 
					                    'BURN_FILE': config.get(section, 'BURN_FILE'),
 | 
				
			||||||
                    'BURN_INT': config.getint(section, 'BURN_INT'),
 | 
					                    'BURN_INT': config.getint(section, 'BURN_INT'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										27
									
								
								hblink.py
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								hblink.py
									
									
									
									
									
								
							@ -254,7 +254,7 @@ class HBSYSTEM(DatagramProtocol):
 | 
				
			|||||||
            self.datagramReceived = self.peer_datagramReceived
 | 
					            self.datagramReceived = self.peer_datagramReceived
 | 
				
			||||||
            self.dereg = self.peer_dereg
 | 
					            self.dereg = self.peer_dereg
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
    def check_user_man(self, _id, server_name, peer_ip):
 | 
					    def check_user_man(self, _id, server_name, peer_ip, _system):
 | 
				
			||||||
        #Change this to a config value
 | 
					        #Change this to a config value
 | 
				
			||||||
        user_man_url = self._CONFIG['USER_MANAGER']['URL']
 | 
					        user_man_url = self._CONFIG['USER_MANAGER']['URL']
 | 
				
			||||||
        shared_secret = str(sha256(self._CONFIG['USER_MANAGER']['SHARED_SECRET'].encode()).hexdigest())
 | 
					        shared_secret = str(sha256(self._CONFIG['USER_MANAGER']['SHARED_SECRET'].encode()).hexdigest())
 | 
				
			||||||
@ -263,7 +263,8 @@ class HBSYSTEM(DatagramProtocol):
 | 
				
			|||||||
        'secret':shared_secret,
 | 
					        'secret':shared_secret,
 | 
				
			||||||
        'login_id':int(str(int_id(_id))[:7]),
 | 
					        'login_id':int(str(int_id(_id))[:7]),
 | 
				
			||||||
        'login_ip': peer_ip,
 | 
					        'login_ip': peer_ip,
 | 
				
			||||||
        'login_server': server_name
 | 
					        'login_server': server_name,
 | 
				
			||||||
 | 
					        'system': _system
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        json_object = json.dumps(auth_check, indent = 4)
 | 
					        json_object = json.dumps(auth_check, indent = 4)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
@ -299,7 +300,7 @@ class HBSYSTEM(DatagramProtocol):
 | 
				
			|||||||
        burn_id = ast.literal_eval(os.popen('cat ' + self._CONFIG['USER_MANAGER']['BURN_FILE']).read())
 | 
					        burn_id = ast.literal_eval(os.popen('cat ' + self._CONFIG['USER_MANAGER']['BURN_FILE']).read())
 | 
				
			||||||
        peer_id_trimmed = int(str(int_id(peer_id))[:7])
 | 
					        peer_id_trimmed = int(str(int_id(peer_id))[:7])
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            print(self.ums_response)
 | 
					##            print(self.ums_response)
 | 
				
			||||||
            if self.ums_response['mode'] == 'legacy':
 | 
					            if self.ums_response['mode'] == 'legacy':
 | 
				
			||||||
                _calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
 | 
					                _calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
 | 
				
			||||||
                calc_passphrase = self._config['PASSPHRASE']
 | 
					                calc_passphrase = self._config['PASSPHRASE']
 | 
				
			||||||
@ -311,11 +312,14 @@ class HBSYSTEM(DatagramProtocol):
 | 
				
			|||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    if burn_id[peer_id_trimmed]:
 | 
					                    if burn_id[peer_id_trimmed]:
 | 
				
			||||||
                        logger.info('User ID has been burned. Requiring passphrase version: ' + str(burn_id[peer_id_trimmed]))
 | 
					                        logger.info('User ID has been burned. Requiring passphrase version: ' + str(burn_id[peer_id_trimmed]))
 | 
				
			||||||
                        calc_passphrase = base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))
 | 
					                        calc_passphrase = sha256(str(self._CONFIG['USER_MANAGER']['EXTRA_1']).encode() + str(self._CONFIG['USER_MANAGER']['EXTRA_INT_1']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))+ sha256(str(self._CONFIG['USER_MANAGER']['EXTRA_2']).encode() + str(self._CONFIG['USER_MANAGER']['EXTRA_INT_2']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
 | 
				
			||||||
                except:
 | 
					                except:
 | 
				
			||||||
                    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)))
 | 
					                    # + base64.b64encode(str.encode(str(_new_peer_id) + self._CONFIG['USER_MANAGER']['EXTRA_3'] + str(self._CONFIG['USER_MANAGER']['EXTRA_INT_1'] - self._CONFIG['USER_MANAGER']['APPEND_INT'])  + str(_new_peer_id) + self._CONFIG['USER_MANAGER']['EXTRA_2']))
 | 
				
			||||||
 | 
					                    calc_passphrase = sha256(str(self._CONFIG['USER_MANAGER']['EXTRA_1']).encode() + str(self._CONFIG['USER_MANAGER']['EXTRA_INT_1']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + 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))) + sha256(str(self._CONFIG['USER_MANAGER']['EXTRA_2']).encode() + str(self._CONFIG['USER_MANAGER']['EXTRA_INT_2']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
 | 
				
			||||||
 | 
					##                    print(base64.b64encode(calc_passphrase))
 | 
				
			||||||
                if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == True:
 | 
					                if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == True:
 | 
				
			||||||
                    calc_passphrase = calc_passphrase[-8:]
 | 
					##                    print(calc_passphrase)
 | 
				
			||||||
 | 
					                    calc_passphrase = calc_passphrase[::int(self._CONFIG['USER_MANAGER']['SHORTEN_SAMPLE'])][-int(self._CONFIG['USER_MANAGER']['SHORTEN_LENGTH']):]
 | 
				
			||||||
                if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == False:
 | 
					                if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == False:
 | 
				
			||||||
                    pass
 | 
					                    pass
 | 
				
			||||||
                _calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
 | 
					                _calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
 | 
				
			||||||
@ -325,17 +329,17 @@ class HBSYSTEM(DatagramProtocol):
 | 
				
			|||||||
            _new_peer_id = bytes_4(int(str(int_id(peer_id))[:7]))
 | 
					            _new_peer_id = bytes_4(int(str(int_id(peer_id))[:7]))
 | 
				
			||||||
            if peer_id_trimmed in burn_id:
 | 
					            if peer_id_trimmed in burn_id:
 | 
				
			||||||
                logger.info('User ID has been burned. Requiring passphrase version: ' + str(burn_id[peer_id_trimmed]))
 | 
					                logger.info('User ID has been burned. Requiring passphrase version: ' + str(burn_id[peer_id_trimmed]))
 | 
				
			||||||
                calc_passphrase = base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))
 | 
					                calc_passphrase = sha256(str(self._CONFIG['USER_MANAGER']['EXTRA_1']).encode() + str(self._CONFIG['USER_MANAGER']['EXTRA_INT_1']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + burn_id[peer_id_trimmed].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['BURN_INT'].to_bytes(2, 'big') + self._CONFIG['USER_MANAGER']['APPEND_INT'].to_bytes(2, 'big'))))[2:].zfill(8))) + sha256(str(self._CONFIG['USER_MANAGER']['EXTRA_2']).encode() + str(self._CONFIG['USER_MANAGER']['EXTRA_INT_2']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                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)))
 | 
					                calc_passphrase = sha256(str(self._CONFIG['USER_MANAGER']['EXTRA_1']).encode() + str(self._CONFIG['USER_MANAGER']['EXTRA_INT_1']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + 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))) + sha256(str(self._CONFIG['USER_MANAGER']['EXTRA_2']).encode() + str(self._CONFIG['USER_MANAGER']['EXTRA_INT_2']).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #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)))
 | 
					            #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)))
 | 
				
			||||||
            if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == True:
 | 
					            if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == True:
 | 
				
			||||||
                calc_passphrase = calc_passphrase[-8:]
 | 
					                calc_passphrase = calc_passphrase[::int(self._CONFIG['USER_MANAGER']['SHORTEN_SAMPLE'])][-int(self._CONFIG['USER_MANAGER']['SHORTEN_LENGTH']):]
 | 
				
			||||||
            if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == False:
 | 
					            if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == False:
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
            _calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
 | 
					            _calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
 | 
				
			||||||
        print(calc_passphrase)
 | 
					##        print(calc_passphrase)
 | 
				
			||||||
        #    print(_calc_hash)
 | 
					        #    print(_calc_hash)
 | 
				
			||||||
        return _calc_hash
 | 
					        return _calc_hash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -520,7 +524,7 @@ class HBSYSTEM(DatagramProtocol):
 | 
				
			|||||||
                #print(self.check_user_man(_peer_id))
 | 
					                #print(self.check_user_man(_peer_id))
 | 
				
			||||||
                if self._config['USE_USER_MAN'] == True:
 | 
					                if self._config['USE_USER_MAN'] == True:
 | 
				
			||||||
##                    print(str(_peer_id) + ' - hblink.py')
 | 
					##                    print(str(_peer_id) + ' - hblink.py')
 | 
				
			||||||
                    self.ums_response = self.check_user_man(_peer_id, self._CONFIG['USER_MANAGER']['THIS_SERVER_NAME'], _sockaddr[0])
 | 
					                    self.ums_response = self.check_user_man(_peer_id, self._CONFIG['USER_MANAGER']['THIS_SERVER_NAME'], _sockaddr[0], self._system)
 | 
				
			||||||
##                    print(self.ums_response)
 | 
					##                    print(self.ums_response)
 | 
				
			||||||
                    #Will allow anyone to attempt authentication, used for a transition period
 | 
					                    #Will allow anyone to attempt authentication, used for a transition period
 | 
				
			||||||
##                    if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and self.ums_response['allow'] or 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 self.ums_response['allow'] or acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']):
 | 
				
			||||||
@ -528,7 +532,6 @@ class HBSYSTEM(DatagramProtocol):
 | 
				
			|||||||
                        user_auth = self.ums_response['allow']
 | 
					                        user_auth = self.ums_response['allow']
 | 
				
			||||||
                    else:
 | 
					                    else:
 | 
				
			||||||
                        user_auth = False
 | 
					                        user_auth = False
 | 
				
			||||||
##                    print(user_auth)
 | 
					 | 
				
			||||||
                if self._config['USE_USER_MAN'] == False:
 | 
					                if self._config['USE_USER_MAN'] == False:
 | 
				
			||||||
                   # print('False')
 | 
					                   # print('False')
 | 
				
			||||||
                    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']):
 | 
				
			||||||
 | 
				
			|||||||
@ -473,12 +473,14 @@ def create_app():
 | 
				
			|||||||
            #print(b_list)
 | 
					            #print(b_list)
 | 
				
			||||||
            if ui[0] == trimmed_id:
 | 
					            if ui[0] == trimmed_id:
 | 
				
			||||||
                if ui[0] != 0:
 | 
					                if ui[0] != 0:
 | 
				
			||||||
                    calc_passphrase = base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + b_list[trimmed_id].to_bytes(2, 'big') + burn_int.to_bytes(2, 'big') + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + b_list[trimmed_id].to_bytes(2, 'big') + burn_int.to_bytes(2, 'big') + append_int.to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + b_list[trimmed_id].to_bytes(2, 'big') + burn_int.to_bytes(2, 'big') + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + b_list[trimmed_id].to_bytes(2, 'big') + burn_int.to_bytes(2, 'big') + append_int.to_bytes(2, 'big'))))[2:].zfill(8)))
 | 
					                    calc_passphrase = hashlib.sha256(str(extra_1).encode() + str(extra_int_1).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + b_list[trimmed_id].to_bytes(2, 'big') + burn_int.to_bytes(2, 'big') + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + b_list[trimmed_id].to_bytes(2, 'big') + burn_int.to_bytes(2, 'big') + append_int.to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + b_list[trimmed_id].to_bytes(2, 'big') + burn_int.to_bytes(2, 'big') + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + b_list[trimmed_id].to_bytes(2, 'big') + burn_int.to_bytes(2, 'big') + append_int.to_bytes(2, 'big'))))[2:].zfill(8))) + hashlib.sha256(str(extra_2).encode() + str(extra_int_2).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
 | 
				
			||||||
                    burned = True
 | 
					                    burned = True
 | 
				
			||||||
        if burned == False:
 | 
					        if burned == False:
 | 
				
			||||||
            calc_passphrase = base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + append_int.to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + append_int.to_bytes(2, 'big'))))[2:].zfill(8)))
 | 
					            calc_passphrase = hashlib.sha256(str(extra_1).encode() + str(extra_int_1).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14] + base64.b64encode(bytes.fromhex(str(hex(libscrc.ccitt((_new_peer_id) + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + append_int.to_bytes(2, 'big'))))[2:].zfill(8)))))[2:].zfill(4)) + (_new_peer_id) + append_int.to_bytes(2, 'big') + bytes.fromhex(str(hex(libscrc.posix((_new_peer_id) + append_int.to_bytes(2, 'big'))))[2:].zfill(8))) + hashlib.sha256(str(extra_2).encode() + str(extra_int_2).encode() + str(_new_peer_id).encode()[-3:]).hexdigest().upper().encode()[::14]
 | 
				
			||||||
        if use_short_passphrase == True:
 | 
					        if use_short_passphrase == True:
 | 
				
			||||||
            return str(calc_passphrase)[-9:-1]
 | 
					            trim_pass = str(calc_passphrase)[2:-1]
 | 
				
			||||||
 | 
					            new_pass = trim_pass[::int(shorten_sample)][-int(shorten_length):]
 | 
				
			||||||
 | 
					            return str(new_pass)
 | 
				
			||||||
        elif use_short_passphrase ==False:
 | 
					        elif use_short_passphrase ==False:
 | 
				
			||||||
            return str(calc_passphrase)[2:-1]
 | 
					            return str(calc_passphrase)[2:-1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -569,16 +571,16 @@ def create_app():
 | 
				
			|||||||
    @login_required
 | 
					    @login_required
 | 
				
			||||||
    def gen():
 | 
					    def gen():
 | 
				
			||||||
        #print(str(gen_passphrase(3153591))) #(int(i[0])))
 | 
					        #print(str(gen_passphrase(3153591))) #(int(i[0])))
 | 
				
			||||||
        try:
 | 
					##        try:
 | 
				
			||||||
            #content = Markup('<strong>The HTML String</strong>')
 | 
					            #content = Markup('<strong>The HTML String</strong>')
 | 
				
			||||||
            #user_id = request.args.get('user_id')
 | 
					            #user_id = request.args.get('user_id')
 | 
				
			||||||
        u = current_user
 | 
					        u = current_user
 | 
				
			||||||
    ##        print(u.username)
 | 
					##        print(u.username)
 | 
				
			||||||
        id_dict = ast.literal_eval(u.dmr_ids)
 | 
					        id_dict = ast.literal_eval(u.dmr_ids)
 | 
				
			||||||
        #u = User.query.filter_by(username=user).first()
 | 
					        #u = User.query.filter_by(username=user).first()
 | 
				
			||||||
    ##        print(user_id)
 | 
					##        print(user_id)
 | 
				
			||||||
    ##        print(request.args.get('mode'))
 | 
					##        print(request.args.get('mode'))
 | 
				
			||||||
    ##        if request.args.get('mode') == 'generated':
 | 
					##        if request.args.get('mode') == 'generated':
 | 
				
			||||||
        #print(id_dict)
 | 
					        #print(id_dict)
 | 
				
			||||||
        content = '\n'
 | 
					        content = '\n'
 | 
				
			||||||
        for i in id_dict.items():
 | 
					        for i in id_dict.items():
 | 
				
			||||||
@ -656,8 +658,8 @@ def create_app():
 | 
				
			|||||||
        <p> </p>
 | 
					        <p> </p>
 | 
				
			||||||
'''
 | 
					'''
 | 
				
			||||||
            #content = content + '\n\n' + str(script_links[i[0]])
 | 
					            #content = content + '\n\n' + str(script_links[i[0]])
 | 
				
			||||||
        except:
 | 
					##        except:
 | 
				
			||||||
            content = Markup('<strong>No DMR IDs found or other error.</strong>')
 | 
					##            content = Markup('<strong>No DMR IDs found or other error.</strong>')
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        #return str(content)
 | 
					        #return str(content)
 | 
				
			||||||
@ -1464,6 +1466,18 @@ def create_app():
 | 
				
			|||||||
        content = '<p style="text-align: center;">Currently active talkgroups. Updated every 2 minutes.</p>'
 | 
					        content = '<p style="text-align: center;">Currently active talkgroups. Updated every 2 minutes.</p>'
 | 
				
			||||||
        for s in sl:
 | 
					        for s in sl:
 | 
				
			||||||
            for i in user_ids.items():
 | 
					            for i in user_ids.items():
 | 
				
			||||||
 | 
					                for ts in active_tgs.items():
 | 
				
			||||||
 | 
					                    for x in ts[1]:
 | 
				
			||||||
 | 
					                        print(x)
 | 
				
			||||||
 | 
					                        print(s.name)
 | 
				
			||||||
 | 
					##                    print(active_tgs[s.name])
 | 
				
			||||||
 | 
					##                        print(str(active_tgs[ts[1]]))
 | 
				
			||||||
 | 
					                # Remove 0 from TG list
 | 
				
			||||||
 | 
					                        try:
 | 
				
			||||||
 | 
					                            active_tgs[s.name][x][0]['1'].remove(0)
 | 
				
			||||||
 | 
					                            active_tgs[s.name][x][1]['2'].remove(0)
 | 
				
			||||||
 | 
					                        except:
 | 
				
			||||||
 | 
					                            pass
 | 
				
			||||||
##                try:
 | 
					##                try:
 | 
				
			||||||
                        content = content + ''' <table style="width: 500px; margin-left: auto; margin-right: auto;" border="1">
 | 
					                        content = content + ''' <table style="width: 500px; margin-left: auto; margin-right: auto;" border="1">
 | 
				
			||||||
<tbody>
 | 
					<tbody>
 | 
				
			||||||
@ -1479,11 +1493,11 @@ def create_app():
 | 
				
			|||||||
<tbody>
 | 
					<tbody>
 | 
				
			||||||
<tr>
 | 
					<tr>
 | 
				
			||||||
<td style="width: 85.7px;"><strong>Timeslot 1</strong></td>
 | 
					<td style="width: 85.7px;"><strong>Timeslot 1</strong></td>
 | 
				
			||||||
<td style="width: 377.3px;"> ''' + str(active_tgs[s.name][i[0]][0]['1'])[1:-1] + '''</td>
 | 
					<td style="width: 377.3px;"> ''' + str(active_tgs[s.name][x][0]['1'])[1:-1] + '''</td>
 | 
				
			||||||
</tr>
 | 
					</tr>
 | 
				
			||||||
<tr>
 | 
					<tr>
 | 
				
			||||||
<td style="width: 85.7px;"><strong>Timeslot 2</strong></td>
 | 
					<td style="width: 85.7px;"><strong>Timeslot 2</strong></td>
 | 
				
			||||||
<td style="width: 377.3px;"> ''' + str(active_tgs[s.name][i[0]][1]['2'])[1:-1] + '''</td>
 | 
					<td style="width: 377.3px;"> ''' + str(active_tgs[s.name][x][1]['2'])[1:-1] + '''</td>
 | 
				
			||||||
</tr>
 | 
					</tr>
 | 
				
			||||||
</tbody>
 | 
					</tbody>
 | 
				
			||||||
</table>
 | 
					</table>
 | 
				
			||||||
@ -4778,7 +4792,8 @@ def create_app():
 | 
				
			|||||||
                                    mode='override',
 | 
					                                    mode='override',
 | 
				
			||||||
                                    value=authorized_peer(hblink_req['login_id'])[1]
 | 
					                                    value=authorized_peer(hblink_req['login_id'])[1]
 | 
				
			||||||
                                        )
 | 
					                                        )
 | 
				
			||||||
                        active_tgs[hblink_req['login_server']][hblink_req['login_id']] = [{'1':[]}, {'2':[]}, {'SYSTEM': ''}]
 | 
					                        active_tgs[hblink_req['login_server']][hblink_req['system']] = [{'1':[]}, {'2':[]}, {'SYSTEM': ''}, {'peer_id':hblink_req['login_id']}]
 | 
				
			||||||
 | 
					                        print(active_tgs)
 | 
				
			||||||
                    elif authorized_peer(hblink_req['login_id'])[0] == False:
 | 
					                    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')
 | 
					                        authlog_add(hblink_req['login_id'], hblink_req['login_ip'], hblink_req['login_server'], 'Not Registered', '-', 'Failed')
 | 
				
			||||||
@ -4849,32 +4864,83 @@ def create_app():
 | 
				
			|||||||
            elif 'update_tg' in hblink_req:
 | 
					            elif 'update_tg' in hblink_req:
 | 
				
			||||||
                if hblink_req['update_tg']:
 | 
					                if hblink_req['update_tg']:
 | 
				
			||||||
                    print(hblink_req)
 | 
					                    print(hblink_req)
 | 
				
			||||||
 | 
					##                    print(hblink_req['data'][0]['SYSTEM'])
 | 
				
			||||||
                    if 'on' == hblink_req['mode']:
 | 
					                    if 'on' == hblink_req['mode']:
 | 
				
			||||||
                        active_tgs[hblink_req['update_tg']][hblink_req['dmr_id']][2]['SYSTEM'] = hblink_req['data'][0]['SYSTEM']
 | 
					##                        try:
 | 
				
			||||||
##                        active_tgs[hblink_req['update_tg']][hblink_req['dmr_id']].update({hblink_req['data'][0]['SYSTEM']: [{1:[hblink_req['data'][1]['ts1']]}, {2:[hblink_req['data'][2]['ts2']]}]}) #.update({[hblink_req['dmr_id']]:hblink_req['data']})
 | 
					                              if hblink_req['dmr_id'] == 0:
 | 
				
			||||||
                        if hblink_req['data'][1]['ts1'] not in active_tgs[hblink_req['update_tg']][hblink_req['dmr_id']][0]['1']:
 | 
					                                print('id 0')
 | 
				
			||||||
                            active_tgs[hblink_req['update_tg']][hblink_req['dmr_id']][0]['1'].append(hblink_req['data'][1]['ts1'])
 | 
					##                                print(active_tgs)
 | 
				
			||||||
                        if hblink_req['data'][2]['ts2'] not in active_tgs[hblink_req['update_tg']][hblink_req['dmr_id']][1]['2']:
 | 
					 | 
				
			||||||
                            active_tgs[hblink_req['update_tg']][hblink_req['dmr_id']][1]['2'].append(hblink_req['data'][2]['ts2'])
 | 
					 | 
				
			||||||
                    elif 'off' == hblink_req['mode']:
 | 
					 | 
				
			||||||
                                for system in active_tgs[hblink_req['update_tg']].items():
 | 
					                                for system in active_tgs[hblink_req['update_tg']].items():
 | 
				
			||||||
                            if system[1][2]['SYSTEM'] == hblink_req['data'][0]['SYSTEM']:
 | 
					    ##                                print(system)
 | 
				
			||||||
##                                print(system[0])
 | 
					    ##                                print('sys')
 | 
				
			||||||
##                                print(active_tgs[hblink_req['update_tg']][system[0]])
 | 
					                                    if system[0] == hblink_req['data'][0]['SYSTEM']:
 | 
				
			||||||
                                new_ts = str(hblink_req['data'][1]['ts'])
 | 
					                                        print(active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][0]['1'])
 | 
				
			||||||
 | 
					##                                        print(hblink_req['data'][2]['tg'])
 | 
				
			||||||
 | 
					                                        print('---------')
 | 
				
			||||||
 | 
					                                        print(active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][1]['2'])
 | 
				
			||||||
 | 
					        ##                                print(hblink_req['data'][1]['ts'])
 | 
				
			||||||
                                        if hblink_req['data'][1]['ts'] == 1:
 | 
					                                        if hblink_req['data'][1]['ts'] == 1:
 | 
				
			||||||
##                                    print(active_tgs[hblink_req['update_tg']][system[0]][0]['1'])
 | 
					        ####                                  print(active_tgs[hblink_req['update_tg']][system[0]][0]['1'])
 | 
				
			||||||
                                    active_tgs[hblink_req['update_tg']][system[0]][0]['1'].remove(hblink_req['data'][2]['tg'])
 | 
					
 | 
				
			||||||
##                                    active_tgs[hblink_req['update_tg']][system[0]][0]['1'].append(0)
 | 
					                                            if active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][0]['1'] == hblink_req['data'][2]['tg']:
 | 
				
			||||||
 | 
					                                                pass
 | 
				
			||||||
 | 
					                                            else:
 | 
				
			||||||
 | 
					                                                active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][0]['1'].append(hblink_req['data'][2]['tg'])
 | 
				
			||||||
 | 
					        ####                                    active_tgs[hblink_req['update_tg']][system[0]][0]['1'].append(0)
 | 
				
			||||||
                                        if hblink_req['data'][1]['ts'] == 2:
 | 
					                                        if hblink_req['data'][1]['ts'] == 2:
 | 
				
			||||||
##                                    print(active_tgs[hblink_req['update_tg']][system[0]][1]['2'])
 | 
					                                            if active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][1]['2'] == hblink_req['data'][2]['tg']:
 | 
				
			||||||
                                    active_tgs[hblink_req['update_tg']][system[0]][1]['2'].remove(hblink_req['data'][2]['tg'])
 | 
					                                                pass
 | 
				
			||||||
##                                    active_tgs[hblink_req['update_tg']][system[0]][1]['2'].append(0)
 | 
					        ####                                    print(active_tgs[hblink_req['update_tg']][system[0]][1]['2'])
 | 
				
			||||||
 | 
					                                            else:
 | 
				
			||||||
 | 
					                                                active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][1]['2'].append(hblink_req['data'][2]['tg'])
 | 
				
			||||||
 | 
					                              else:
 | 
				
			||||||
 | 
					                                    print('---------on------------')
 | 
				
			||||||
 | 
					                                    print(hblink_req['data'])
 | 
				
			||||||
 | 
					                                    print(active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][1]['2'])
 | 
				
			||||||
 | 
					                                    print(hblink_req['data'][2]['ts2'])
 | 
				
			||||||
 | 
					                                    print('-----------------------')
 | 
				
			||||||
 | 
					        ##                        active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][2]['SYSTEM'] = hblink_req['data'][0]['SYSTEM']
 | 
				
			||||||
 | 
					        ####                        active_tgs[hblink_req['update_tg']][hblink_req['dmr_id']].update({hblink_req['data'][0]['SYSTEM']: [{1:[hblink_req['data'][1]['ts1']]}, {2:[hblink_req['data'][2]['ts2']]}]}) #.update({[hblink_req['dmr_id']]:hblink_req['data']})
 | 
				
			||||||
 | 
					                                    if hblink_req['data'][1]['ts1'] not in active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][0]['1']:
 | 
				
			||||||
 | 
					                                        active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][0]['1'].append(hblink_req['data'][1]['ts1'])
 | 
				
			||||||
 | 
					                                    if hblink_req['data'][2]['ts2'] not in active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][1]['2']:
 | 
				
			||||||
 | 
					                                        active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][1]['2'].append(hblink_req['data'][2]['ts2'])
 | 
				
			||||||
 | 
					##                                        print('append')
 | 
				
			||||||
 | 
					        ####                                    active_tgs[hblink_req['update_tg']][system[0]][1]['2'].append(0)
 | 
				
			||||||
 | 
					        ##                        print(hblink_req['data'][0]['SYSTEM'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ##                            print(active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']])
 | 
				
			||||||
 | 
					    ##                            print(active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][2]['2'])
 | 
				
			||||||
 | 
					    ##                            print(hblink_req['data'][1]['ts2'])
 | 
				
			||||||
 | 
					        ##                        print(active_tgs[hblink_req['update_tg']])
 | 
				
			||||||
 | 
					                                
 | 
				
			||||||
 | 
					##                        except:
 | 
				
			||||||
 | 
					##                            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            
 | 
				
			||||||
 | 
					                    elif 'off' == hblink_req['mode']:
 | 
				
			||||||
 | 
					                        print('off')
 | 
				
			||||||
 | 
					                        for system in active_tgs[hblink_req['update_tg']].items():
 | 
				
			||||||
 | 
					                            print(system)
 | 
				
			||||||
 | 
					                            if system[0] == hblink_req['data'][0]['SYSTEM']:
 | 
				
			||||||
 | 
					                                print('yes it is')
 | 
				
			||||||
 | 
					####                                print(system[0])
 | 
				
			||||||
 | 
					####                                print(active_tgs[hblink_req['update_tg']][system[0]])
 | 
				
			||||||
 | 
					                                if hblink_req['data'][1]['ts'] == 1:
 | 
				
			||||||
 | 
					####                                    print(active_tgs[hblink_req['update_tg']][system[0]][0]['1'])
 | 
				
			||||||
 | 
					                                    active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][0]['1'].remove(hblink_req['data'][2]['tg'])
 | 
				
			||||||
 | 
					####                                    active_tgs[hblink_req['update_tg']][system[0]][0]['1'].append(0)
 | 
				
			||||||
 | 
					                                if hblink_req['data'][1]['ts'] == 2:
 | 
				
			||||||
 | 
					####                                    print(active_tgs[hblink_req['update_tg']][system[0]][1]['2'])
 | 
				
			||||||
 | 
					                                    active_tgs[hblink_req['update_tg']][hblink_req['data'][0]['SYSTEM']][1]['2'].remove(hblink_req['data'][2]['tg'])
 | 
				
			||||||
 | 
					####                                    active_tgs[hblink_req['update_tg']][system[0]][1]['2'].append(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
##                            print()
 | 
					##                            print()
 | 
				
			||||||
##                            print(system)
 | 
					##                            print(system)
 | 
				
			||||||
##                            print(system[1][2]['SYSTEM'])
 | 
					##                            print(system[1][2]['SYSTEM'])
 | 
				
			||||||
                        print('off')
 | 
					##                        print('off')
 | 
				
			||||||
##                        print(hblink_req['data'][1]['ts'])
 | 
					##                        print(hblink_req['data'][1]['ts'])
 | 
				
			||||||
##                        print(hblink_req['data'][2]['tg'])
 | 
					##                        print(hblink_req['data'][2]['tg'])
 | 
				
			||||||
                print(active_tgs)
 | 
					                print(active_tgs)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user