diff options
Diffstat (limited to 'toxcore/onion_client.c')
-rw-r--r-- | toxcore/onion_client.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 73cb1f75..16333e0c 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -509,6 +509,7 @@ static int handle_fakeid_announce(void *object, uint8_t *source_pubkey, uint8_t | |||
509 | } | 509 | } |
510 | 510 | ||
511 | onion_c->friends_list[friend_num].is_fake_clientid = 1; | 511 | onion_c->friends_list[friend_num].is_fake_clientid = 1; |
512 | onion_c->friends_list[friend_num].fake_client_id_timestamp = current_time_monotonic(); | ||
512 | memcpy(onion_c->friends_list[friend_num].fake_client_id, data + 1 + sizeof(uint64_t), crypto_box_PUBLICKEYBYTES); | 513 | memcpy(onion_c->friends_list[friend_num].fake_client_id, data + 1 + sizeof(uint64_t), crypto_box_PUBLICKEYBYTES); |
513 | } | 514 | } |
514 | 515 | ||
@@ -814,22 +815,22 @@ int onion_delfriend(Onion_Client *onion_c, int friend_num) | |||
814 | 815 | ||
815 | /* Copy friends DHT public key into dht_key. | 816 | /* Copy friends DHT public key into dht_key. |
816 | * | 817 | * |
817 | * return -1 on failure (no key copied). | 818 | * return 0 on failure (no key copied). |
818 | * return 0 on success (key copied). | 819 | * return timestamp on success (key copied). |
819 | */ | 820 | */ |
820 | int onion_getfriend_DHT_pubkey(Onion_Client *onion_c, int friend_num, uint8_t *dht_key) | 821 | uint64_t onion_getfriend_DHT_pubkey(Onion_Client *onion_c, int friend_num, uint8_t *dht_key) |
821 | { | 822 | { |
822 | if ((uint32_t)friend_num >= onion_c->num_friends) | 823 | if ((uint32_t)friend_num >= onion_c->num_friends) |
823 | return -1; | 824 | return 0; |
824 | 825 | ||
825 | if (onion_c->friends_list[friend_num].status == 0) | 826 | if (onion_c->friends_list[friend_num].status == 0) |
826 | return -1; | 827 | return 0; |
827 | 828 | ||
828 | if (!onion_c->friends_list[friend_num].is_fake_clientid) | 829 | if (!onion_c->friends_list[friend_num].is_fake_clientid) |
829 | return -1; | 830 | return 0; |
830 | 831 | ||
831 | memcpy(dht_key, onion_c->friends_list[friend_num].fake_client_id, crypto_box_PUBLICKEYBYTES); | 832 | memcpy(dht_key, onion_c->friends_list[friend_num].fake_client_id, crypto_box_PUBLICKEYBYTES); |
832 | return 0; | 833 | return onion_c->friends_list[friend_num].fake_client_id_timestamp; |
833 | } | 834 | } |
834 | 835 | ||
835 | /* Get the ip of friend friendnum and put it in ip_port | 836 | /* Get the ip of friend friendnum and put it in ip_port |
@@ -843,7 +844,7 @@ int onion_getfriendip(Onion_Client *onion_c, int friend_num, IP_Port *ip_port) | |||
843 | { | 844 | { |
844 | uint8_t dht_public_key[crypto_box_PUBLICKEYBYTES]; | 845 | uint8_t dht_public_key[crypto_box_PUBLICKEYBYTES]; |
845 | 846 | ||
846 | if (onion_getfriend_DHT_pubkey(onion_c, friend_num, dht_public_key) != 0) | 847 | if (onion_getfriend_DHT_pubkey(onion_c, friend_num, dht_public_key) == 0) |
847 | return -1; | 848 | return -1; |
848 | 849 | ||
849 | return DHT_getfriendip(onion_c->dht, dht_public_key, ip_port); | 850 | return DHT_getfriendip(onion_c->dht, dht_public_key, ip_port); |