From c69290072819d20e43bd0dd83fa8cefc1167b544 Mon Sep 17 00:00:00 2001 From: Andrea Shepard Date: Tue, 28 Jun 2016 16:12:58 +0000 Subject: Add bridge descriptor download status queries to GETINFO --- src/or/entrynodes.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/or/entrynodes.c') diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 68241af987..72ac6e7e4f 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -2424,6 +2424,44 @@ num_bridges_usable(void) return n_options; } +/** Return a smartlist containing all bridge identity digests */ +smartlist_t * +list_bridge_identities(void) +{ + smartlist_t *result = NULL; + char *digest_tmp; + + if (get_options()->UseBridges && bridge_list) { + result = smartlist_new(); + + SMARTLIST_FOREACH_BEGIN(bridge_list, bridge_info_t *, b) { + digest_tmp = tor_malloc(DIGEST_LEN); + memcpy(digest_tmp, b->identity, DIGEST_LEN); + smartlist_add(result, digest_tmp); + } SMARTLIST_FOREACH_END(b); + } + + return result; +} + +/** Get the download status for a bridge descriptor given its identity */ +download_status_t * +get_bridge_dl_status_by_id(const char *digest) +{ + download_status_t *dl = NULL; + + if (digest && get_options()->UseBridges && bridge_list) { + SMARTLIST_FOREACH_BEGIN(bridge_list, bridge_info_t *, b) { + if (memcmp(digest, b->identity, DIGEST_LEN) == 0) { + dl = &(b->fetch_status); + break; + } + } SMARTLIST_FOREACH_END(b); + } + + return dl; +} + /** Return 1 if we have at least one descriptor for an entry guard * (bridge or member of EntryNodes) and all descriptors we know are * down. Else return 0. If act is 1, then mark the down guards -- cgit v1.2.3-54-g00ecf