summaryrefslogtreecommitdiff
path: root/src/or/routerlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-08-29 15:02:11 -0400
committerNick Mathewson <nickm@torproject.org>2016-08-29 15:02:11 -0400
commitbbaa7d09a045130560a2f5da579671c5e02c9cd7 (patch)
tree232540453f40eb00b2dc0492b236967f383627e8 /src/or/routerlist.c
parentf46ce6e3d8bea3cf00388c87c29cdcafd4bab350 (diff)
parent19816f2f782568722964d35ee132af441a809db3 (diff)
downloadtor-bbaa7d09a045130560a2f5da579671c5e02c9cd7.tar.gz
tor-bbaa7d09a045130560a2f5da579671c5e02c9cd7.zip
Merge remote-tracking branch 'teor/reject-tap-v6'
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r--src/or/routerlist.c51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 1773f1d05c..74b8d1b1d3 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2260,10 +2260,16 @@ router_add_running_nodes_to_smartlist(smartlist_t *sl, int allow_invalid,
continue;
if (node_is_unreliable(node, need_uptime, need_capacity, need_guard))
continue;
- /* Choose a node with an OR address that matches the firewall rules,
- * if we are making a direct connection */
+ /* Don't choose nodes if we are certain they can't do ntor */
+ if (node->rs && !routerstatus_version_supports_ntor(node->rs, 1))
+ continue;
+ if ((node->ri || node->md) && !node_has_curve25519_onion_key(node))
+ continue;
+ /* Choose a node with an OR address that matches the firewall rules */
if (direct_conn && check_reach &&
- !fascist_firewall_allows_node(node, FIREWALL_OR_CONNECTION, pref_addr))
+ !fascist_firewall_allows_node(node,
+ FIREWALL_OR_CONNECTION,
+ pref_addr))
continue;
smartlist_add(sl, (void *)node);
@@ -5497,6 +5503,45 @@ routerinfo_incompatible_with_extrainfo(const crypto_pk_t *identity_pkey,
return r;
}
+/* Does ri have a valid ntor onion key?
+ * Valid ntor onion keys exist and have at least one non-zero byte. */
+int
+routerinfo_has_curve25519_onion_key(const routerinfo_t *ri)
+{
+ if (!ri) {
+ return 0;
+ }
+
+ if (!ri->onion_curve25519_pkey) {
+ return 0;
+ }
+
+ if (tor_mem_is_zero((const char*)ri->onion_curve25519_pkey->public_key,
+ CURVE25519_PUBKEY_LEN)) {
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Is rs running a tor version known to support ntor?
+ * If allow_unknown_versions is true, return true if the version is unknown.
+ * Otherwise, return false if the version is unknown. */
+int
+routerstatus_version_supports_ntor(const routerstatus_t *rs,
+ int allow_unknown_versions)
+{
+ if (!rs) {
+ return allow_unknown_versions;
+ }
+
+ if (!rs->version_known) {
+ return allow_unknown_versions;
+ }
+
+ return rs->version_supports_extend2_cells;
+}
+
/** Assert that the internal representation of <b>rl</b> is
* self-consistent. */
void