]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
nodelist: Add functions to check for HS v3 support
authorDavid Goulet <dgoulet@torproject.org>
Tue, 2 May 2017 19:50:33 +0000 (15:50 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 27 Jun 2017 14:24:15 +0000 (10:24 -0400)
This introduces node_supports_v3_hsdir() and node_supports_ed25519_hs_intro()
that checks the routerstatus_t of a node and if not present, checks the
routerinfo_t.

This is groundwork for proposal 224 service implementation in #20657.

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/or/nodelist.c
src/or/nodelist.h

index 0ef9741243dcea200146c55ffab0070825ece60a..a04f4154b722eb5030c34e15e8e70ccd38d18803 100644 (file)
@@ -707,6 +707,48 @@ node_supports_ed25519_link_authentication(const node_t *node)
   return 0;
 }
 
+/** Return true iff <b>node</b> supports the hidden service directory version
+ * 3 protocol (proposal 224). */
+int
+node_supports_v3_hsdir(const node_t *node)
+{
+  tor_assert(node);
+
+  if (node->rs) {
+    return node->rs->supports_v3_hsdir;
+  }
+  if (node->ri) {
+    if (node->ri->protocol_list == NULL) {
+      return 0;
+    }
+    return protocol_list_supports_protocol(node->ri->protocol_list,
+                                           PRT_HSDIR, 2);
+  }
+  tor_assert_nonfatal_unreached_once();
+  return 0;
+}
+
+/** Return true iff <b>node</b> supports ed25519 authentication as an hidden
+ * service introduction point.*/
+int
+node_supports_ed25519_hs_intro(const node_t *node)
+{
+  tor_assert(node);
+
+  if (node->rs) {
+    return node->rs->supports_ed25519_hs_intro;
+  }
+  if (node->ri) {
+    if (node->ri->protocol_list == NULL) {
+      return 0;
+    }
+    return protocol_list_supports_protocol(node->ri->protocol_list,
+                                           PRT_HSINTRO, 4);
+  }
+  tor_assert_nonfatal_unreached_once();
+  return 0;
+}
+
 /** Return the RSA ID key's SHA1 digest for the provided node. */
 const uint8_t *
 node_get_rsa_id_digest(const node_t *node)
index 6c063de8a3ba06bfc5745bf8b6c7a957ea47da05..f59e767d1ef2f45e0e71fb05f5cffaf7335c7169 100644 (file)
@@ -58,6 +58,8 @@ const ed25519_public_key_t *node_get_ed25519_id(const node_t *node);
 int node_ed25519_id_matches(const node_t *node,
                             const ed25519_public_key_t *id);
 int node_supports_ed25519_link_authentication(const node_t *node);
+int node_supports_v3_hsdir(const node_t *node);
+int node_supports_ed25519_hs_intro(const node_t *node);
 const uint8_t *node_get_rsa_id_digest(const node_t *node);
 
 int node_has_ipv6_addr(const node_t *node);