commit 6a320b99058ff19a2b71425e7cd6f267798411be Merge: 0a4a3de 385c597 Author: Nick Mathewson nickm@torproject.org Date: Thu Jun 2 13:05:00 2011 -0400
Merge remote-tracking branch 'origin/maint-0.2.2'
This merge was a bit nontrivial, since I had to write a new node_is_a_configured_bridge to parallel router_is_a_configured_bridge.
Conflicts: src/or/circuitbuild.c
changes/bug3321 | 7 +++++++ src/or/circuitbuild.c | 24 ++++++++++++++++++++++++ src/or/circuitbuild.h | 1 + 3 files changed, 32 insertions(+), 0 deletions(-)
diff --cc src/or/circuitbuild.c index 8140cc4,3f08448..96cd333 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@@ -3388,17 -3377,18 +3388,19 @@@ entry_guard_set_status(entry_guard_t *e *reason = NULL;
/* Do we want to mark this guard as bad? */ - if (!ri) + if (!node) *reason = "unlisted"; - else if (!ri->is_running) + else if (!node->is_running) *reason = "down"; - else if (options->UseBridges && ri->purpose != ROUTER_PURPOSE_BRIDGE) + else if (options->UseBridges && (!node->ri || + node->ri->purpose != ROUTER_PURPOSE_BRIDGE)) *reason = "not a bridge"; - else if (options->UseBridges && !routerinfo_is_a_configured_bridge(ri)) ++ else if (options->UseBridges && !node_is_a_configured_bridge(node)) + *reason = "not a configured bridge"; - else if (!options->UseBridges && !ri->is_possible_guard && - !routerset_contains_router(options->EntryNodes,ri)) + else if (!options->UseBridges && !node->is_possible_guard && + !routerset_contains_node(options->EntryNodes,node)) *reason = "not recommended as a guard"; - else if (routerset_contains_router(options->ExcludeNodes, ri)) + else if (routerset_contains_node(options->ExcludeNodes, node)) *reason = "excluded";
if (*reason && ! e->bad_since) { @@@ -3484,14 -3474,16 +3486,18 @@@ entry_is_live(entry_guard_t *e, int nee *msg = "not a bridge"; return NULL; } - if (!routerinfo_is_a_configured_bridge(r)) { ++ if (!node_is_a_configured_bridge(node)) { + *msg = "not a configured bridge"; + return NULL; + } - } else if (r->purpose != ROUTER_PURPOSE_GENERAL) { - *msg = "not general-purpose"; - return NULL; + } else { /* !get_options()->UseBridges */ + if (node_get_purpose(node) != ROUTER_PURPOSE_GENERAL) { + *msg = "not general-purpose"; + return NULL; + } } if (options->EntryNodes && - routerset_contains_router(options->EntryNodes, r)) { + routerset_contains_node(options->EntryNodes, node)) { /* they asked for it, they get it */ need_uptime = need_capacity = 0; } @@@ -4584,6 -4575,6 +4590,24 @@@ routerinfo_is_a_configured_bridge(cons return get_configured_bridge_by_routerinfo(ri) ? 1 : 0; }
++/** Return 1 if <b>node</b> is one of our configured bridges, else 0. */ ++int ++node_is_a_configured_bridge(const node_t *node) ++{ ++ tor_addr_t addr; ++ uint16_t orport; ++ if (!node) ++ return 0; ++ if (node_get_addr(node, &addr) < 0) ++ return 0; ++ orport = node_get_orport(node); ++ if (orport == 0) ++ return 0; ++ ++ return get_configured_bridge_by_addr_port_digest( ++ &addr, orport, node->identity) != NULL; ++} ++ /** We made a connection to a router at <b>addr</b>:<b>port</b> * without knowing its digest. Its digest turned out to be <b>digest</b>. * If it was a bridge, and we still don't know its digest, record it. diff --cc src/or/circuitbuild.h index 87adb9a,0e673e1..b1eb5a6 --- a/src/or/circuitbuild.h +++ b/src/or/circuitbuild.h @@@ -65,7 -64,7 +65,8 @@@ int getinfo_helper_entry_guards(control
void mark_bridge_list(void); void sweep_bridge_list(void); -int routerinfo_is_a_configured_bridge(routerinfo_t *ri); +int routerinfo_is_a_configured_bridge(const routerinfo_t *ri); ++int node_is_a_configured_bridge(const node_t *node); void learned_router_identity(const tor_addr_t *addr, uint16_t port, const char *digest); void bridge_add_from_config(const tor_addr_t *addr, uint16_t port,