Revert "fix: Allow onion paths to be built from more random nodes."

This reverts commit 5073882e0f.
This commit is contained in:
iphydf 2022-04-11 09:34:47 +00:00
parent 365ecd57f2
commit efea12ed6f
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
3 changed files with 13 additions and 5 deletions

View File

@ -1 +1 @@
a12aa241a079e5f014a6689e48905a5a32c2fd455676cad431773908bda9245c /usr/local/bin/tox-bootstrapd
f20ba5a6917e5faee9a2a6439b448d3ced7cd177ba666ff1804882f494ea7b90 /usr/local/bin/tox-bootstrapd

View File

@ -2589,6 +2589,9 @@ static uint16_t list_nodes(const Random *rng, const Client_data *list, size_t le
}
/** @brief Put up to max_num nodes in nodes from the random friends.
*
* Important: this function relies on the first two DHT friends *not* being real
* friends to avoid leaking information about real friends into the onion paths.
*
* @return the number of nodes.
*/
@ -2598,12 +2601,14 @@ uint16_t randfriends_nodes(const DHT *dht, Node_format *nodes, uint16_t max_num)
return 0;
}
assert(dht->num_friends >= DHT_FAKE_FRIEND_NUMBER);
const uint32_t r = random_range_u32(dht->rng, dht->num_friends - DHT_FAKE_FRIEND_NUMBER);
uint16_t count = 0;
const uint32_t r = random_u32(dht->rng);
for (uint32_t i = 0; i < DHT_FAKE_FRIEND_NUMBER && i < dht->num_friends; ++i) {
count += list_nodes(dht->rng, dht->friends_list[r + i].client_list,
assert(DHT_FAKE_FRIEND_NUMBER <= dht->num_friends);
// Only gather nodes from the initial 2 fake friends.
for (uint32_t i = 0; i < DHT_FAKE_FRIEND_NUMBER; ++i) {
count += list_nodes(dht->rng, dht->friends_list[(i + r) % DHT_FAKE_FRIEND_NUMBER].client_list,
MAX_FRIEND_CLIENTS, dht->cur_time,
nodes + count, max_num - count);

View File

@ -410,6 +410,9 @@ int get_close_nodes(const DHT *dht, const uint8_t *public_key, Node_format *node
/** @brief Put up to max_num nodes in nodes from the random friends.
*
* Important: this function relies on the first two DHT friends *not* being real
* friends to avoid leaking information about real friends into the onion paths.
*
* @return the number of nodes.
*/