@@ -5485,7 +5485,9 @@ static bool send_gc_handshake_packet(const GC_Chat *chat, GC_Connection *gconn,
54855485 Node_format node ;
54865486 memset (& node , 0 , sizeof (node ));
54875487
5488- gcc_copy_tcp_relay (chat -> rng , & node , gconn );
5488+ if (!gcc_copy_tcp_relay (chat -> rng , & node , gconn )) {
5489+ LOGGER_TRACE (chat -> log , "Failed to copy TCP relay during handshake (%u TCP relays)" , gconn -> tcp_relays_count );
5490+ }
54895491
54905492 uint8_t packet [GC_MIN_ENCRYPTED_HS_PAYLOAD_SIZE + sizeof (Node_format )];
54915493 const int length = make_gc_handshake_packet (chat , gconn , handshake_type , request_type , join_type , packet ,
@@ -5658,6 +5660,7 @@ static int handle_gc_handshake_request(GC_Chat *chat, const IP_Port *ipp, const
56585660 }
56595661
56605662 if (chat -> connection_state <= CS_DISCONNECTED ) {
5663+ LOGGER_DEBUG (chat -> log , "Handshake request ignored; state is disconnected" );
56615664 return -1 ;
56625665 }
56635666
@@ -5688,6 +5691,7 @@ static int handle_gc_handshake_request(GC_Chat *chat, const IP_Port *ipp, const
56885691 GC_Connection * gconn = get_gc_connection (chat , peer_number );
56895692
56905693 if (gconn == nullptr ) {
5694+ LOGGER_WARNING (chat -> log , "Invalid peer number" );
56915695 return -1 ;
56925696 }
56935697
@@ -5700,13 +5704,15 @@ static int handle_gc_handshake_request(GC_Chat *chat, const IP_Port *ipp, const
57005704 // peers sent handshake request at same time so the closer peer becomes the requestor
57015705 // and ignores the request packet while further peer continues on with the response
57025706 if (gconn -> self_is_closer ) {
5707+ LOGGER_DEBUG (chat -> log , "Simultaneous handshake requests; other peer is closer" );
57035708 return 0 ;
57045709 }
57055710 }
57065711
57075712 GC_Connection * gconn = get_gc_connection (chat , peer_number );
57085713
57095714 if (gconn == nullptr ) {
5715+ LOGGER_DEBUG (chat -> log , "Peer connection invalid" );
57105716 return -1 ;
57115717 }
57125718
@@ -5720,7 +5726,7 @@ static int handle_gc_handshake_request(GC_Chat *chat, const IP_Port *ipp, const
57205726
57215727 if (nodes_count <= 0 && ipp == nullptr ) {
57225728 if (is_new_peer ) {
5723- LOGGER_WARNING (chat -> log , "broken tcp relay for new peer" );
5729+ LOGGER_WARNING (chat -> log , "Broken tcp relay for new peer" );
57245730 gcc_mark_for_deletion (gconn , chat -> tcp_conn , GC_EXIT_TYPE_DISCONNECTED , nullptr , 0 );
57255731 }
57265732
@@ -5732,7 +5738,7 @@ static int handle_gc_handshake_request(GC_Chat *chat, const IP_Port *ipp, const
57325738 & node -> ip_port , node -> public_key );
57335739
57345740 if (add_tcp_result < 0 && is_new_peer && ipp == nullptr ) {
5735- LOGGER_WARNING (chat -> log , "broken tcp relay for new peer" );
5741+ LOGGER_WARNING (chat -> log , "Broken tcp relay for new peer" );
57365742 gcc_mark_for_deletion (gconn , chat -> tcp_conn , GC_EXIT_TYPE_DISCONNECTED , nullptr , 0 );
57375743 return -1 ;
57385744 }
@@ -5750,6 +5756,7 @@ static int handle_gc_handshake_request(GC_Chat *chat, const IP_Port *ipp, const
57505756
57515757 if (join_type == HJ_PUBLIC && !is_public_chat (chat )) {
57525758 gcc_mark_for_deletion (gconn , chat -> tcp_conn , GC_EXIT_TYPE_DISCONNECTED , nullptr , 0 );
5759+ LOGGER_DEBUG (chat -> log , "Ignoring invalid invite request" );
57535760 return -1 ;
57545761 }
57555762
@@ -7876,6 +7883,8 @@ int handle_gc_invite_confirmed_packet(const GC_Session *c, int friend_number, co
78767883
78777884 if (num_nodes > 0 ) {
78787885 tcp_relays_added = add_gc_tcp_relays (chat , gconn , tcp_relays , num_nodes );
7886+ } else {
7887+ LOGGER_WARNING (chat -> log , "Invite confirm packet did not contain any TCP relays" );
78797888 }
78807889
78817890 if (tcp_relays_added == 0 && !copy_ip_port_result ) {
@@ -7990,7 +7999,7 @@ int gc_accept_invite(GC_Session *c, int32_t friend_number, const uint8_t *data,
79907999 const uint8_t * chat_id = data ;
79918000 const uint8_t * invite_chat_pk = data + CHAT_ID_SIZE ;
79928001
7993- const int group_number = create_new_group (c , nick , nick_length , false, GI_PRIVATE );
8002+ const int group_number = create_new_group (c , nick , nick_length , false, GI_PUBLIC );
79948003
79958004 if (group_number == -1 ) {
79968005 return -2 ;
0 commit comments