tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 73453580adfb72d4ab88b082fe3e97929041380b
parent d7be1595e714b21189f9b3cc80c571a7eba9bcc0
Author: Nick Mathewson <nickm@torproject.org>
Date:   Tue, 11 Feb 2025 08:44:22 -0500

Cache values of use_family_{keys,lists} params.

Diffstat:
Msrc/feature/nodelist/nodelist.c | 28++++++++++++++++++++++++++++
1 file changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c @@ -680,6 +680,32 @@ get_estimated_address_per_node, (void)) return ESTIMATED_ADDRESS_PER_NODE; } +/** + * If true, we use relays' listed family members in order to + * determine which relays are in the same family. + */ +static int use_family_lists = 1; +/** + * If true, we use relays' validated family IDs in order to + * determine which relays are in the same family. + */ +static int use_family_ids = 1; + +/** + * Update consensus parameters relevant to nodelist operations. + * + * We need to cache these values rather than searching for them every time + * we check whether two relays are in the same family. + **/ +static void +nodelist_update_consensus_params(const networkstatus_t *ns) +{ + use_family_lists = networkstatus_get_param(ns, "use-family-lists", + 1, 0, 1); // default, low, high + use_family_ids = networkstatus_get_param(ns, "use-family-ids", + 1, 0, 1); // default, low, high +} + /** Tell the nodelist that the current usable consensus is <b>ns</b>. * This makes the nodelist change all of the routerstatus entries for * the nodes, drop nodes that no longer have enough info to get used, @@ -698,6 +724,8 @@ nodelist_set_consensus(const networkstatus_t *ns) SMARTLIST_FOREACH(the_nodelist->nodes, node_t *, node, node->rs = NULL); + nodelist_update_consensus_params(ns); + /* Conservatively estimate that every node will have 2 addresses (v4 and * v6). Then we add the number of configured trusted authorities we have. */ int estimated_addresses = smartlist_len(ns->routerstatus_list) *