summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/net_crypto.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/core/net_crypto.c b/core/net_crypto.c
index a9af3430..8fcb62e1 100644
--- a/core/net_crypto.c
+++ b/core/net_crypto.c
@@ -669,10 +669,6 @@ static void receive_crypto(void)
669 uint8_t session_key[crypto_box_PUBLICKEYBYTES]; 669 uint8_t session_key[crypto_box_PUBLICKEYBYTES];
670 uint16_t len; 670 uint16_t len;
671 671
672 if (id_packet(crypto_connections[i].number) == 1)
673 /* if the packet is a friend request drop it (because we are already friends) */
674 len = read_packet(crypto_connections[i].number, temp_data);
675
676 if (id_packet(crypto_connections[i].number) == 2) { /* handle handshake packet. */ 672 if (id_packet(crypto_connections[i].number) == 2) { /* handle handshake packet. */
677 len = read_packet(crypto_connections[i].number, temp_data); 673 len = read_packet(crypto_connections[i].number, temp_data);
678 674
@@ -690,9 +686,10 @@ static void receive_crypto(void)
690 crypto_connections[i].status = CONN_NOT_CONFIRMED; /* set it to its proper value right after. */ 686 crypto_connections[i].status = CONN_NOT_CONFIRMED; /* set it to its proper value right after. */
691 } 687 }
692 } 688 }
693 } else if (id_packet(crypto_connections[i].number) != -1) // This should not happen kill the connection if it does 689 } else if (id_packet(crypto_connections[i].number) != -1) { // This should not happen kill the connection if it does
694 crypto_kill(crypto_connections[i].number); 690 crypto_kill(crypto_connections[i].number);
695 691 return;
692 }
696 } 693 }
697 694
698 if (crypto_connections[i].status == CONN_NOT_CONFIRMED) { 695 if (crypto_connections[i].status == CONN_NOT_CONFIRMED) {
@@ -714,12 +711,16 @@ static void receive_crypto(void)
714 711
715 /* connection is accepted so we disable the auto kill by setting it to about 1 month from now. */ 712 /* connection is accepted so we disable the auto kill by setting it to about 1 month from now. */
716 kill_connection_in(crypto_connections[i].number, 3000000); 713 kill_connection_in(crypto_connections[i].number, 3000000);
717 } else 714 } else {
718 crypto_kill(crypto_connections[i].number); // This should not happen kill the connection if it does 715 crypto_kill(crypto_connections[i].number); // This should not happen kill the connection if it does
716 return;
717 }
719 } else if (id_packet(crypto_connections[i].number) != -1) 718 } else if (id_packet(crypto_connections[i].number) != -1)
720 /* This should not happen 719 /* This should not happen
721 kill the connection if it does */ 720 kill the connection if it does */
722 crypto_kill(crypto_connections[i].number); 721 crypto_kill(crypto_connections[i].number);
722
723 return;
723 } 724 }
724 } 725 }
725} 726}