diff options
author | Andrea Shepard <andrea@torproject.org> | 2016-06-28 16:12:58 +0000 |
---|---|---|
committer | Andrea Shepard <andrea@torproject.org> | 2016-06-29 05:55:42 +0000 |
commit | c69290072819d20e43bd0dd83fa8cefc1167b544 (patch) | |
tree | 0feb54bdba2e36c441b46f267f6e69b12e2d1984 /src/or/entrynodes.c | |
parent | 8798ca4be299855a9a87a48df772081e06e9040c (diff) | |
download | tor-c69290072819d20e43bd0dd83fa8cefc1167b544.tar.gz tor-c69290072819d20e43bd0dd83fa8cefc1167b544.zip |
Add bridge descriptor download status queries to GETINFO
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r-- | src/or/entrynodes.c | 38 |
1 files changed, 38 insertions, 0 deletions
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 <b>act</b> is 1, then mark the down guards |