summaryrefslogtreecommitdiff
path: root/src/or/hs_common.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-04-16 10:38:55 -0400
committerNick Mathewson <nickm@torproject.org>2018-04-22 19:42:26 -0400
commit948dd2c79ea9ca1fd06c13f275515a1745c46986 (patch)
treeafc311f00bca225b6745b4778a73f38d741c6eb9 /src/or/hs_common.c
parent22845df2a7503ed73ed325c3a98916f289918caa (diff)
downloadtor-948dd2c79ea9ca1fd06c13f275515a1745c46986.tar.gz
tor-948dd2c79ea9ca1fd06c13f275515a1745c46986.zip
Check for "the right descriptor", not just "any descriptor".
This patch adds a new node_has_preferred_descriptor() function, and replaces most users of node_has_descriptor() with it. That's an important change, since as of d1874b433953f64 (our fix for #25213), we are willing to say that a node has _some_ descriptor, but not the _right_ descriptor for a particular use case. Part of a fix for 25691 and 25692.
Diffstat (limited to 'src/or/hs_common.c')
-rw-r--r--src/or/hs_common.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index 6d97c8775c..10b56c0baa 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -1280,8 +1280,10 @@ node_has_hsdir_index(const node_t *node)
tor_assert(node_supports_v3_hsdir(node));
/* A node can't have an HSDir index without a descriptor since we need desc
- * to get its ed25519 key */
- if (!node_has_descriptor(node)) {
+ * to get its ed25519 key. for_direct_connect should be zero, since we
+ * always use the consensus-indexed node's keys to build the hash ring, even
+ * if some of the consensus-indexed nodes are also bridges. */
+ if (!node_has_preferred_descriptor(node, 0)) {
return 0;
}
@@ -1612,12 +1614,17 @@ hs_pick_hsdir(smartlist_t *responsible_dirs, const char *req_key_str)
hs_clean_last_hid_serv_requests(now);
/* Only select those hidden service directories to which we did not send a
- * request recently and for which we have a router descriptor here. */
+ * request recently and for which we have a router descriptor here.
+ *
+ * Use for_direct_connect==0 even if we will be connecting to the node
+ * directly, since we always use the key information in the
+ * consensus-indexed node descriptors for building the index.
+ **/
SMARTLIST_FOREACH_BEGIN(responsible_dirs, routerstatus_t *, dir) {
time_t last = hs_lookup_last_hid_serv_request(dir, req_key_str, 0, 0);
const node_t *node = node_get_by_id(dir->identity_digest);
if (last + hs_hsdir_requery_period(options) >= now ||
- !node || !node_has_descriptor(node)) {
+ !node || !node_has_preferred_descriptor(node, 0)) {
SMARTLIST_DEL_CURRENT(responsible_dirs, dir);
continue;
}