diff options
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r-- | toxcore/DHT.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index f7d460d8..db03def1 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -708,29 +708,43 @@ int addto_lists(DHT *dht, IP_Port ip_port, const uint8_t *client_id) | |||
708 | } else | 708 | } else |
709 | used++; | 709 | used++; |
710 | 710 | ||
711 | DHT_Friend *friend_foundip = 0; | ||
712 | |||
711 | for (i = 0; i < dht->num_friends; ++i) { | 713 | for (i = 0; i < dht->num_friends; ++i) { |
712 | if (!client_or_ip_port_in_list(dht->friends_list[i].client_list, | 714 | if (!client_or_ip_port_in_list(dht->friends_list[i].client_list, |
713 | MAX_FRIEND_CLIENTS, client_id, ip_port)) { | 715 | MAX_FRIEND_CLIENTS, client_id, ip_port)) { |
714 | if (replace_all(dht->friends_list[i].client_list, MAX_FRIEND_CLIENTS, | 716 | if (replace_all(dht->friends_list[i].client_list, MAX_FRIEND_CLIENTS, |
715 | client_id, ip_port, dht->friends_list[i].client_id)) { | 717 | client_id, ip_port, dht->friends_list[i].client_id)) { |
718 | |||
716 | DHT_Friend *friend = &dht->friends_list[i]; | 719 | DHT_Friend *friend = &dht->friends_list[i]; |
717 | 720 | ||
718 | if (memcmp(client_id, friend->client_id, CLIENT_ID_SIZE) == 0) { | 721 | if (memcmp(client_id, friend->client_id, CLIENT_ID_SIZE) == 0) { |
719 | uint32_t j; | 722 | friend_foundip = friend; |
720 | |||
721 | for (j = 0; j < friend->lock_count; ++j) { | ||
722 | if (friend->callbacks[j].ip_callback) | ||
723 | friend->callbacks[j].ip_callback(friend->callbacks[j].data, friend->callbacks[j].number, ip_port); | ||
724 | } | ||
725 | } | 723 | } |
726 | 724 | ||
727 | used++; | 725 | used++; |
728 | } | 726 | } |
729 | } else { | 727 | } else { |
728 | DHT_Friend *friend = &dht->friends_list[i]; | ||
729 | |||
730 | if (memcmp(client_id, friend->client_id, CLIENT_ID_SIZE) == 0) { | ||
731 | friend_foundip = friend; | ||
732 | } | ||
733 | |||
730 | used++; | 734 | used++; |
731 | } | 735 | } |
732 | } | 736 | } |
733 | 737 | ||
738 | if (friend_foundip) { | ||
739 | uint32_t j; | ||
740 | |||
741 | for (j = 0; j < friend_foundip->lock_count; ++j) { | ||
742 | if (friend_foundip->callbacks[j].ip_callback) | ||
743 | friend_foundip->callbacks[j].ip_callback(friend_foundip->callbacks[j].data, friend_foundip->callbacks[j].number, | ||
744 | ip_port); | ||
745 | } | ||
746 | } | ||
747 | |||
734 | #ifdef ENABLE_ASSOC_DHT | 748 | #ifdef ENABLE_ASSOC_DHT |
735 | 749 | ||
736 | if (dht->assoc) { | 750 | if (dht->assoc) { |