This fixes an issue where nodes could stay unannounced for certain

periods of time.

Online nodes should now be able to announce themselves continuously.
This commit is contained in:
irungentoo 2014-09-06 22:14:13 -04:00
parent df7a627fde
commit 64ce60c585
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 13 additions and 6 deletions

View File

@ -333,10 +333,14 @@ static int handle_announce_request(void *object, IP_Port source, const uint8_t *
pl[0] = 0; pl[0] = 0;
memcpy(pl + 1, ping_id2, ONION_PING_ID_SIZE); memcpy(pl + 1, ping_id2, ONION_PING_ID_SIZE);
} else { } else {
if (memcmp(onion_a->entries[index].public_key, packet_public_key, crypto_box_PUBLICKEYBYTES) == 0 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) { if (memcmp(onion_a->entries[index].data_public_key, data_public_key, crypto_box_PUBLICKEYBYTES) != 0) {
pl[0] = 0; pl[0] = 0;
memcpy(pl + 1, ping_id2, ONION_PING_ID_SIZE); memcpy(pl + 1, ping_id2, ONION_PING_ID_SIZE);
} else {
pl[0] = 2;
memcpy(pl + 1, ping_id2, ONION_PING_ID_SIZE);
}
} else { } else {
pl[0] = 1; pl[0] = 1;
memcpy(pl + 1, onion_a->entries[index].data_public_key, crypto_box_PUBLICKEYBYTES); memcpy(pl + 1, onion_a->entries[index].data_public_key, crypto_box_PUBLICKEYBYTES);

View File

@ -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; list_nodes = onion_c->clients_announce_list;
reference_id = onion_c->c->self_public_key; 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; is_stored = 0;
} }
} else { } else {
if (is_stored == 2)
return -1;
list_nodes = onion_c->friends_list[num - 1].clients_list; list_nodes = onion_c->friends_list[num - 1].clients_list;
reference_id = onion_c->friends_list[num - 1].real_client_id; 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. //TODO: remove this and find a better source of nodes to use for paths.
onion_add_path_node(onion_c, ip_port, public_key); 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); memcpy(list_nodes[index].data_public_key, pingid_or_key, crypto_box_PUBLICKEYBYTES);
} else { } else {
memcpy(list_nodes[index].ping_id, pingid_or_key, ONION_PING_ID_SIZE); memcpy(list_nodes[index].ping_id, pingid_or_key, ONION_PING_ID_SIZE);