diff options
author | juga0 <juga@riseup.net> | 2018-11-02 18:38:46 +0000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-03-26 17:40:45 +1000 |
commit | 3eacae42b2ade91bc5d0e3761dce1e785aad7621 (patch) | |
tree | b96814cc2caf15a63ce8d82db4765ef58c5ec748 /src/feature/dircache/dircache.c | |
parent | 41cd05562f68c23f8c3d95472e20a86165f6dc20 (diff) | |
download | tor-3eacae42b2ade91bc5d0e3761dce1e785aad7621.tar.gz tor-3eacae42b2ade91bc5d0e3761dce1e785aad7621.zip |
Serve bandwidth file used in the next vote
When a directory authority is using a bandwidth file to obtain the
bandwidth values that will be included in the next vote, serve this
bandwidth file at /tor/status-vote/next/bandwidth.z.
Diffstat (limited to 'src/feature/dircache/dircache.c')
-rw-r--r-- | src/feature/dircache/dircache.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/feature/dircache/dircache.c b/src/feature/dircache/dircache.c index e8cb284165..f373b74c85 100644 --- a/src/feature/dircache/dircache.c +++ b/src/feature/dircache/dircache.c @@ -357,12 +357,15 @@ static int handle_get_robots(dir_connection_t *conn, const get_handler_args_t *args); static int handle_get_networkstatus_bridges(dir_connection_t *conn, const get_handler_args_t *args); +static int handle_get_next_bandwidth(dir_connection_t *conn, + const get_handler_args_t *args); /** Table for handling GET requests. */ static const url_table_ent_t url_table[] = { { "/tor/", 0, handle_get_frontpage }, { "/tor/status-vote/current/consensus", 1, handle_get_current_consensus }, { "/tor/status-vote/current/", 1, handle_get_status_vote }, + { "/tor/status-vote/next/bandwidth", 0, handle_get_next_bandwidth }, { "/tor/status-vote/next/", 1, handle_get_status_vote }, { "/tor/micro/d/", 1, handle_get_microdesc }, { "/tor/server/", 1, handle_get_descriptor }, @@ -1438,6 +1441,27 @@ handle_get_networkstatus_bridges(dir_connection_t *conn, return 0; } +/** Helper function for GET the bandwidth file used for the next vote */ +static int +handle_get_next_bandwidth(dir_connection_t *conn, + const get_handler_args_t *args) +{ + (void)args; + log_debug(LD_DIR, "Getting next bandwidth."); + const or_options_t *options = get_options(); + if (options->V3BandwidthsFile) { + int lifetime = 60; + char *bandwidth = read_file_to_str(options->V3BandwidthsFile, 0, NULL); + size_t len = strlen(bandwidth); + write_http_response_header(conn, len, NO_METHOD, lifetime); + connection_buf_add(bandwidth, len, TO_CONN(conn)); + tor_free(bandwidth); + } else { + write_short_http_response(conn, 404, "Not found"); + } + return 0; +} + /** Helper function for GET robots.txt or /tor/robots.txt */ static int handle_get_robots(dir_connection_t *conn, const get_handler_args_t *args) |