ssb: New incoming connections replace old ones for the same id.
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Build Tilde Friends / Build-All (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Build Tilde Friends / Build-All (push) Has been cancelled
				
			This commit is contained in:
		
							
								
								
									
										16
									
								
								src/ssb.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/ssb.c
									
									
									
									
									
								
							| @@ -1404,7 +1404,7 @@ tf_ssb_connection_t* tf_ssb_connection_get_tunnel(tf_ssb_connection_t* connectio | ||||
| 	return connection ? connection->tunnel_connection : NULL; | ||||
| } | ||||
|  | ||||
| static bool _tf_ssb_is_already_connected(tf_ssb_t* ssb, uint8_t* id, tf_ssb_connection_t* ignore_connection) | ||||
| static tf_ssb_connection_t* _tf_ssb_is_already_connected(tf_ssb_t* ssb, uint8_t* id, tf_ssb_connection_t* ignore_connection) | ||||
| { | ||||
| 	for (tf_ssb_connection_t* connection = ssb->connections; connection; connection = connection->next) | ||||
| 	{ | ||||
| @@ -1412,15 +1412,15 @@ static bool _tf_ssb_is_already_connected(tf_ssb_t* ssb, uint8_t* id, tf_ssb_conn | ||||
| 		{ | ||||
| 			if (memcmp(connection->serverpub, id, k_id_bin_len) == 0) | ||||
| 			{ | ||||
| 				return true; | ||||
| 				return connection; | ||||
| 			} | ||||
| 			else if (memcmp(ssb->pub, id, k_id_bin_len) == 0) | ||||
| 			{ | ||||
| 				return true; | ||||
| 				return connection; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return false; | ||||
| 	return NULL; | ||||
| } | ||||
|  | ||||
| static void _tf_ssb_connection_is_account_a_stranger_work(tf_ssb_connection_t* connection, void* user_data) | ||||
| @@ -1538,14 +1538,14 @@ static void _tf_ssb_connection_verify_client_identity(tf_ssb_connection_t* conne | ||||
| 	} | ||||
| 	uint8_t* detached_signature_A = m; | ||||
|  | ||||
| 	if (_tf_ssb_is_already_connected(connection->ssb, m + 64, connection)) | ||||
| 	tf_ssb_connection_t* other_connection = NULL; | ||||
| 	while ((other_connection = _tf_ssb_is_already_connected(connection->ssb, m + 64, connection))) | ||||
| 	{ | ||||
| 		char id_base64[k_id_base64_len] = { 0 }; | ||||
| 		tf_ssb_id_bin_to_str(id_base64, sizeof(id_base64), m + 64); | ||||
| 		char reason[256]; | ||||
| 		snprintf(reason, sizeof(reason), "already connected: %s\n", id_base64); | ||||
| 		tf_ssb_connection_close(connection, reason); | ||||
| 		return; | ||||
| 		snprintf(reason, sizeof(reason), "Replacing connection: %s\n", id_base64); | ||||
| 		tf_ssb_connection_close(other_connection, reason); | ||||
| 	} | ||||
|  | ||||
| 	memcpy(connection->serverpub, m + 64, sizeof(connection->serverpub)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user