mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
nodelist: Move the v3 onion service rendezvous check
And delete a loop that is now empty. This change should improve tor's performance, because we no longer iterate through the nodelist twice for every node in every circuit path. Part of 34200.
This commit is contained in:
parent
ce11e3bf69
commit
280195f414
@ -1802,6 +1802,7 @@ pick_restricted_middle_node(router_crn_flags_t flags,
|
||||
(flags & CRN_NEED_DESC) != 0,
|
||||
(flags & CRN_PREF_ADDR) != 0,
|
||||
(flags & CRN_DIRECT_CONN) != 0,
|
||||
(flags & CRN_RENDEZVOUS_V3) != 0,
|
||||
(flags & CRN_INITIATE_IPV6_EXTEND) != 0);
|
||||
|
||||
/* Filter all_live_nodes to only add live *and* whitelisted middles
|
||||
|
@ -973,7 +973,6 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
|
||||
const int rendezvous_v3 = (flags & CRN_RENDEZVOUS_V3) != 0;
|
||||
const bool initiate_ipv6_extend = (flags & CRN_INITIATE_IPV6_EXTEND) != 0;
|
||||
|
||||
const smartlist_t *node_list = nodelist_get_list();
|
||||
smartlist_t *sl=smartlist_new(),
|
||||
*excludednodes=smartlist_new();
|
||||
const node_t *choice = NULL;
|
||||
@ -984,15 +983,6 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
|
||||
rule = weight_for_exit ? WEIGHT_FOR_EXIT :
|
||||
(need_guard ? WEIGHT_FOR_GUARD : WEIGHT_FOR_MID);
|
||||
|
||||
SMARTLIST_FOREACH_BEGIN(node_list, const node_t *, node) {
|
||||
if (rendezvous_v3 &&
|
||||
!node_supports_v3_rendezvous_point(node)) {
|
||||
/* Exclude relays that can not become a rendezvous for a hidden service
|
||||
* version 3. */
|
||||
smartlist_add(excludednodes, (node_t*)node);
|
||||
}
|
||||
} SMARTLIST_FOREACH_END(node);
|
||||
|
||||
/* If the node_t is not found we won't be to exclude ourself but we
|
||||
* won't be able to pick ourself in router_choose_random_node() so
|
||||
* this is fine to at least try with our routerinfo_t object. */
|
||||
@ -1001,7 +991,8 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
|
||||
|
||||
router_add_running_nodes_to_smartlist(sl, need_uptime, need_capacity,
|
||||
need_guard, need_desc, pref_addr,
|
||||
direct_conn, initiate_ipv6_extend);
|
||||
direct_conn, rendezvous_v3,
|
||||
initiate_ipv6_extend);
|
||||
log_debug(LD_CIRC,
|
||||
"We found %d running nodes.",
|
||||
smartlist_len(sl));
|
||||
|
@ -520,6 +520,7 @@ router_add_running_nodes_to_smartlist(smartlist_t *sl, int need_uptime,
|
||||
int need_capacity, int need_guard,
|
||||
int need_desc, int pref_addr,
|
||||
int direct_conn,
|
||||
bool rendezvous_v3,
|
||||
bool initiate_ipv6_extend)
|
||||
{
|
||||
const int check_reach = !router_or_conn_should_skip_reachable_address_check(
|
||||
@ -546,6 +547,11 @@ router_add_running_nodes_to_smartlist(smartlist_t *sl, int need_uptime,
|
||||
* 0.3.1.0-alpha. */
|
||||
if (node_allows_single_hop_exits(node))
|
||||
continue;
|
||||
/* Exclude relays that can not become a rendezvous for a hidden service
|
||||
* version 3. */
|
||||
if (rendezvous_v3 &&
|
||||
!node_supports_v3_rendezvous_point(node))
|
||||
continue;
|
||||
/* Choose a node with an OR address that matches the firewall rules */
|
||||
if (direct_conn && check_reach &&
|
||||
!fascist_firewall_allows_node(node,
|
||||
|
@ -62,6 +62,7 @@ void router_add_running_nodes_to_smartlist(smartlist_t *sl, int need_uptime,
|
||||
int need_capacity, int need_guard,
|
||||
int need_desc, int pref_addr,
|
||||
int direct_conn,
|
||||
bool rendezvous_v3,
|
||||
bool initiate_ipv6_extend);
|
||||
|
||||
const routerinfo_t *routerlist_find_my_routerinfo(void);
|
||||
|
Loading…
Reference in New Issue
Block a user