diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-07-25 22:56:44 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-07-25 22:56:44 +0000 |
commit | a66f25935483b1b415a878ed208896886dd1df66 (patch) | |
tree | 5e3009b8c32a3f5a9a0aafd95b6203e5523c4096 /src/or/directory.c | |
parent | 1b7a704c34443315a1f89280425aa89509a528ee (diff) | |
download | tor-a66f25935483b1b415a878ed208896886dd1df66.tar.gz tor-a66f25935483b1b415a878ed208896886dd1df66.zip |
r13902@catbus: nickm | 2007-07-25 17:43:52 -0400
Some dirvote code to handle generating votes and slinging them around. More code is still needed.
svn:r10927
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index eb3f8ee584..66f182adcf 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -78,6 +78,7 @@ purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose) return 1; /* if we have to ask, better make it anonymous */ if (dir_purpose == DIR_PURPOSE_FETCH_DIR || dir_purpose == DIR_PURPOSE_UPLOAD_DIR || + dir_purpose == DIR_PURPOSE_UPLOAD_VOTE || dir_purpose == DIR_PURPOSE_FETCH_RUNNING_LIST || dir_purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS || dir_purpose == DIR_PURPOSE_FETCH_SERVERDESC || @@ -501,6 +502,9 @@ directory_initiate_command(const char *address, uint32_t addr, case DIR_PURPOSE_UPLOAD_RENDDESC: log_debug(LD_REND,"initiating hidden-service descriptor upload"); break; + case DIR_PURPOSE_UPLOAD_VOTE: + log_debug(LD_OR,"initiating server vote upload"); + break; case DIR_PURPOSE_FETCH_RUNNING_LIST: log_debug(LD_DIR,"initiating running-routers fetch"); break; @@ -685,6 +689,12 @@ directory_send_command(dir_connection_t *conn, httpcommand = "POST"; url = tor_strdup("/tor/"); break; + case DIR_PURPOSE_UPLOAD_VOTE: + tor_assert(!resource); + tor_assert(payload); + httpcommand = "POST"; + url = tor_strdup("/tor/post/vote"); + break; case DIR_PURPOSE_FETCH_RENDDESC: tor_assert(resource); tor_assert(!payload); @@ -1367,6 +1377,30 @@ connection_dir_client_reached_eof(dir_connection_t *conn) * dirservers down just because they don't like us. */ } + if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_VOTE) { + switch (status_code) { + case 200: { + log_notice(LD_DIR,"Uploaded a vote to dirserver %s:%d", + conn->_base.address, conn->_base.port); + } + break; + case 400: + log_warn(LD_GENERAL,"http status 400 (%s) response after uploading " + "vote to dirserver '%s:%d'. Please correct.", + escaped(reason), conn->_base.address, conn->_base.port); + break; + default: + log_warn(LD_GENERAL, + "http status %d (%s) reason unexpected while uploading " + "vote to server '%s:%d').", + status_code, escaped(reason), conn->_base.address, + conn->_base.port); + break; + } + /* return 0 in all cases, since we don't want to mark any + * dirservers down just because they don't like us. */ + } + if (conn->_base.purpose == DIR_PURPOSE_FETCH_RENDDESC) { log_info(LD_REND,"Received rendezvous descriptor (size %d, status %d " "(%s))", @@ -2075,6 +2109,18 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers, goto done; } + if (authdir_mode_v3(options) && + !strcmp(url,"/tor/post/vote")) { /* server descriptor post */ + const char *msg = "OK"; + if (dirserv_add_vote(body, &msg)) { + write_http_status_line(conn, 200, "Vote stored"); + } else { + tor_assert(msg); + write_http_status_line(conn, 400, msg); + } + goto done; + } + /* we didn't recognize the url */ write_http_status_line(conn, 404, "Not found"); |