diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-11-29 11:26:55 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-12-16 11:06:18 -0500 |
commit | 3bcbbea350ccab4bc25b191fcce1dd3fc63775d3 (patch) | |
tree | 36c4447241c6a06a82ffeadb81db1e4ba3acf520 /src/or/bridges.c | |
parent | 82fa71610de1c7d7faed78490a3cb90ce917a3e2 (diff) | |
download | tor-3bcbbea350ccab4bc25b191fcce1dd3fc63775d3.tar.gz tor-3bcbbea350ccab4bc25b191fcce1dd3fc63775d3.zip |
More progress on bridge implementation with prop271 guards
Here we handle most (all?) of the remaining tasks, and fix some
bugs, in the prop271 bridge implementation.
* We record bridge identities as we learn them.
* We only call deprecated functions from bridges.c when the
deprecated guard algorithm is in use.
* We update any_bridge_descriptors_known() and
num_bridges_usable() to work correctly with the new backend
code. (Previously, they called into the guard selection logic.
* We update bridge directory fetches to work with the new
guard code.
* We remove some erroneous assertions where we assumed that we'd
never load a guard that wasn't for the current selection.
Also, we fix a couple of typos.
Diffstat (limited to 'src/or/bridges.c')
-rw-r--r-- | src/or/bridges.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/or/bridges.c b/src/or/bridges.c index 8090bae268..c480e3fb7b 100644 --- a/src/or/bridges.c +++ b/src/or/bridges.c @@ -279,7 +279,8 @@ learned_router_identity(const tor_addr_t *addr, uint16_t port, hex_str(digest, DIGEST_LEN), fmt_addrport(addr, port), transport_info ? transport_info : ""); tor_free(transport_info); - // XXXX prop271 here. we will need to update the guard info too. + entry_guard_learned_bridge_identity(&bridge->addrport_configured, + (const uint8_t *)digest); } } @@ -741,16 +742,21 @@ learned_bridge_descriptor(routerinfo_t *ri, int from_cache) fmt_and_decorate_addr(&bridge->addr), (int) bridge->port); } - // XXXX prop271 here we will need to update the guard info too. - add_bridge_as_entry_guard(get_guard_selection_info(), node); + if (get_options()->UseDeprecatedGuardAlgorithm) { + add_bridge_as_entry_guard(get_guard_selection_info(), node); + } else { + entry_guard_learned_bridge_identity(&bridge->addrport_configured, + (const uint8_t*)ri->cache_info.identity_digest); + } log_notice(LD_DIR, "new bridge descriptor '%s' (%s): %s", ri->nickname, from_cache ? "cached" : "fresh", router_describe(ri)); /* set entry->made_contact so if it goes down we don't drop it from * our entry node list */ - // XXXX prop271 use new interface here when we hit bridges? - entry_guard_register_connect_status(ri->cache_info.identity_digest, - 1, 0, now); + if (get_options()->UseDeprecatedGuardAlgorithm) { + entry_guard_register_connect_status(ri->cache_info.identity_digest, + 1, 0, now); + } if (first) { routerlist_retry_directory_downloads(now); } @@ -768,8 +774,20 @@ int any_bridge_descriptors_known(void) { tor_assert(get_options()->UseBridges); - // XXXX prop271 this needs to get fixed. -- bridges - return choose_random_entry(NULL) != NULL; + + if (!bridge_list) + return 0; + + SMARTLIST_FOREACH_BEGIN(bridge_list, bridge_info_t *, bridge) { + const node_t *node; + if (!tor_digest_is_zero(bridge->identity) && + (node = node_get_by_id(bridge->identity)) != NULL && + node->ri) { + return 1; + } + } SMARTLIST_FOREACH_END(bridge); + + return 0; } /** Return a smartlist containing all bridge identity digests */ |