summaryrefslogtreecommitdiff
path: root/src/or/nodelist.c
diff options
context:
space:
mode:
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-07-07 12:58:47 +1000
committerteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-07-15 09:55:49 +1000
commit579a80d4ae54ec03fd9b02c4a125b2943770c85d (patch)
tree816ee00f3ed7dff2fe350d1a2fcb49469baea1ac /src/or/nodelist.c
parenta76d528bec970e500d3339d9e0f253bded17c338 (diff)
downloadtor-579a80d4ae54ec03fd9b02c4a125b2943770c85d.tar.gz
tor-579a80d4ae54ec03fd9b02c4a125b2943770c85d.zip
Clients avoid choosing nodes that can't do ntor
If we know a node's version, and it can't do ntor, consider it not running. If we have a node's descriptor, and it doesn't have a valid ntor key, consider it not running. Refactor these checks so they're consistent between authorities and clients.
Diffstat (limited to 'src/or/nodelist.c')
-rw-r--r--src/or/nodelist.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index a49bf03f61..a888ebefbd 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -1171,14 +1171,35 @@ node_get_pref_ipv6_dirport(const node_t *node, tor_addr_port_t *ap_out)
}
}
+/** Return true iff <b>md</b> has a curve25519 onion key.
+ * Use node_has_curve25519_onion_key() instead of calling this directly. */
+static int
+microdesc_has_curve25519_onion_key(const microdesc_t *md)
+{
+ if (!md) {
+ return 0;
+ }
+
+ if (!md->onion_curve25519_pkey) {
+ return 0;
+ }
+
+ if (tor_mem_is_zero((const char*)md->onion_curve25519_pkey->public_key,
+ CURVE25519_PUBKEY_LEN)) {
+ return 0;
+ }
+
+ return 1;
+}
+
/** Return true iff <b>node</b> has a curve25519 onion key. */
int
node_has_curve25519_onion_key(const node_t *node)
{
if (node->ri)
- return node->ri->onion_curve25519_pkey != NULL;
+ return routerinfo_has_curve25519_onion_key(node->ri);
else if (node->md)
- return node->md->onion_curve25519_pkey != NULL;
+ return microdesc_has_curve25519_onion_key(node->md);
else
return 0;
}