diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-06-29 15:57:48 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-06-29 15:57:48 -0400 |
commit | 1712dc98b04ef7b84df67e02da21ea1aa70bc74c (patch) | |
tree | 8afe3757200bec46df6496e2763e6f196865359b /src/or/entrynodes.c | |
parent | 31a08ba26fc5eaa12de6d3c5efa3aac4d00509d0 (diff) | |
parent | 52c4440c4895cb90dd155bb094b49a97128baedf (diff) | |
download | tor-1712dc98b04ef7b84df67e02da21ea1aa70bc74c.tar.gz tor-1712dc98b04ef7b84df67e02da21ea1aa70bc74c.zip |
Merge branch 'maint-0.3.0' into maint-0.3.1
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r-- | src/or/entrynodes.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index be9f85a89f..fa768fc4a6 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -1428,6 +1428,38 @@ entry_guard_passes_filter(const or_options_t *options, guard_selection_t *gs, } } +/** Return true iff <b>guard</b> is in the same family as <b>node</b>. + */ +static int +guard_in_node_family(const entry_guard_t *guard, const node_t *node) +{ + const node_t *guard_node = node_get_by_id(guard->identity); + if (guard_node) { + return nodes_in_same_family(guard_node, node); + } else { + /* If we don't have a node_t for the guard node, we might have + * a bridge_info_t for it. So let's check to see whether the bridge + * address matches has any family issues. + * + * (Strictly speaking, I believe this check is unnecessary, since we only + * use it to avoid the exit's family when building circuits, and we don't + * build multihop circuits until we have a routerinfo_t for the + * bridge... at which point, we'll also have a node_t for the + * bridge. Nonetheless, it seems wise to include it, in case our + * assumptions change down the road. -nickm.) + */ + if (get_options()->EnforceDistinctSubnets && guard->bridge_addr) { + tor_addr_t node_addr; + node_get_addr(node, &node_addr); + if (addrs_in_same_network_family(&node_addr, + &guard->bridge_addr->addr)) { + return 1; + } + } + return 0; + } +} + /** * Return true iff <b>guard</b> obeys the restrictions defined in <b>rst</b>. * (If <b>rst</b> is NULL, there are no restrictions.) @@ -1440,7 +1472,12 @@ entry_guard_obeys_restriction(const entry_guard_t *guard, if (! rst) return 1; // No restriction? No problem. - // Only one kind of restriction exists right now + // Only one kind of restriction exists right now: excluding an exit + // ID and all of its family. + const node_t *node = node_get_by_id((const char*)rst->exclude_id); + if (node && guard_in_node_family(guard, node)) + return 0; + return tor_memneq(guard->identity, rst->exclude_id, DIGEST_LEN); } |