diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index baccc95b..b25b6b11 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c @@ -333,10 +333,14 @@ static int handle_announce_request(void *object, IP_Port source, const uint8_t * pl[0] = 0; memcpy(pl + 1, ping_id2, ONION_PING_ID_SIZE); } else { - if (memcmp(onion_a->entries[index].public_key, packet_public_key, crypto_box_PUBLICKEYBYTES) == 0 - && memcmp(onion_a->entries[index].data_public_key, data_public_key, crypto_box_PUBLICKEYBYTES) != 0) { - pl[0] = 0; - memcpy(pl + 1, ping_id2, ONION_PING_ID_SIZE); + if (memcmp(onion_a->entries[index].public_key, packet_public_key, crypto_box_PUBLICKEYBYTES) == 0) { + if (memcmp(onion_a->entries[index].data_public_key, data_public_key, crypto_box_PUBLICKEYBYTES) != 0) { + pl[0] = 0; + memcpy(pl + 1, ping_id2, ONION_PING_ID_SIZE); + } else { + pl[0] = 2; + memcpy(pl + 1, ping_id2, ONION_PING_ID_SIZE); + } } else { pl[0] = 1; memcpy(pl + 1, onion_a->entries[index].data_public_key, crypto_box_PUBLICKEYBYTES); diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 167a26f9..8f735d6c 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c @@ -398,11 +398,14 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t list_nodes = onion_c->clients_announce_list; reference_id = onion_c->c->self_public_key; - if (is_stored && memcmp(pingid_or_key, onion_c->temp_public_key, crypto_box_PUBLICKEYBYTES) != 0) { + if (is_stored == 1 && memcmp(pingid_or_key, onion_c->temp_public_key, crypto_box_PUBLICKEYBYTES) != 0) { is_stored = 0; } } else { + if (is_stored == 2) + return -1; + list_nodes = onion_c->friends_list[num - 1].clients_list; reference_id = onion_c->friends_list[num - 1].real_client_id; } @@ -435,7 +438,7 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t //TODO: remove this and find a better source of nodes to use for paths. onion_add_path_node(onion_c, ip_port, public_key); - if (is_stored) { + if (is_stored == 1) { memcpy(list_nodes[index].data_public_key, pingid_or_key, crypto_box_PUBLICKEYBYTES); } else { memcpy(list_nodes[index].ping_id, pingid_or_key, ONION_PING_ID_SIZE);