|
@@ -1121,6 +1121,30 @@ hs_get_hsdir_spread_store(void)
|
|
|
HS_DEFAULT_HSDIR_SPREAD_STORE, 1, 128);
|
|
|
}
|
|
|
|
|
|
+/** <b>node</b> is an HSDir so make sure that we have assigned an hsdir index.
|
|
|
+ * Return 0 if everything is as expected, else return -1. */
|
|
|
+static int
|
|
|
+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)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* At this point, since the node has a desc, this node must also have an
|
|
|
+ * hsdir index. If not, something went wrong, so BUG out. */
|
|
|
+ if (BUG(node->hsdir_index == NULL) ||
|
|
|
+ BUG(tor_mem_is_zero((const char*)node->hsdir_index->current,
|
|
|
+ DIGEST256_LEN))) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
/* For a given blinded key and time period number, get the responsible HSDir
|
|
|
* and put their routerstatus_t object in the responsible_dirs list. If
|
|
|
* is_next_period is true, the next hsdir_index of the node_t is used. If
|
|
@@ -1162,7 +1186,9 @@ hs_get_responsible_hsdirs(const ed25519_public_key_t *blinded_pk,
|
|
|
node_t *n = node_get_mutable_by_id(rs->identity_digest);
|
|
|
tor_assert(n);
|
|
|
if (node_supports_v3_hsdir(n) && rs->is_hs_dir) {
|
|
|
- if (BUG(n->hsdir_index == NULL)) {
|
|
|
+ if (!node_has_hsdir_index(n)) {
|
|
|
+ log_info(LD_GENERAL, "Node %s was found without hsdir index.",
|
|
|
+ node_describe(n));
|
|
|
continue;
|
|
|
}
|
|
|
smartlist_add(sorted_nodes, n);
|