diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-07-29 02:55:21 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-07-29 02:55:21 +0000 |
commit | d2adb68ed63eebfa8ec3fb58cc28e6428418427f (patch) | |
tree | 05c9361d86ee0c4729928b94561cd30acf294ff8 /src/or | |
parent | 9895d840f597f1a781f79caf7b44760499a22c66 (diff) | |
download | tor-d2adb68ed63eebfa8ec3fb58cc28e6428418427f.tar.gz tor-d2adb68ed63eebfa8ec3fb58cc28e6428418427f.zip |
r13963@catbus: nickm | 2007-07-28 22:53:32 -0400
Add support for signature upload
svn:r10962
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/directory.c | 46 | ||||
-rw-r--r-- | src/or/or.h | 6 |
2 files changed, 49 insertions, 3 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index a60ff13236..ca6aae483d 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -80,6 +80,7 @@ purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose) if (dir_purpose == DIR_PURPOSE_FETCH_DIR || dir_purpose == DIR_PURPOSE_UPLOAD_DIR || dir_purpose == DIR_PURPOSE_UPLOAD_VOTE || + dir_purpose == DIR_PURPOSE_UPLOAD_SIGNATURES || dir_purpose == DIR_PURPOSE_FETCH_RUNNING_LIST || dir_purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS || dir_purpose == DIR_PURPOSE_FETCH_SERVERDESC || @@ -506,6 +507,9 @@ directory_initiate_command(const char *address, uint32_t addr, case DIR_PURPOSE_UPLOAD_VOTE: log_debug(LD_OR,"initiating server vote upload"); break; + case DIR_PURPOSE_UPLOAD_SIGNATURES: + log_debug(LD_OR,"initiating consensus signature upload"); + break; case DIR_PURPOSE_FETCH_RUNNING_LIST: log_debug(LD_DIR,"initiating running-routers fetch"); break; @@ -696,6 +700,12 @@ directory_send_command(dir_connection_t *conn, httpcommand = "POST"; url = tor_strdup("/tor/post/vote"); break; + case DIR_PURPOSE_UPLOAD_SIGNATURES: + 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); @@ -1386,7 +1396,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn) } break; case 400: - log_warn(LD_GENERAL,"http status 400 (%s) response after uploading " + log_warn(LD_DIR,"http status 400 (%s) response after uploading " "vote to dirserver '%s:%d'. Please correct.", escaped(reason), conn->_base.address, conn->_base.port); break; @@ -1402,6 +1412,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_SIGNATURES) { + switch (status_code) { + case 200: { + log_notice(LD_DIR,"Uploaded a signatures to dirserver %s:%d", + conn->_base.address, conn->_base.port); + } + break; + case 400: + log_warn(LD_DIR,"http status 400 (%s) response after uploading " + "signatures 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 " + "signatures 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))", @@ -2122,6 +2156,16 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers, goto done; } + if (authdir_mode_v3(options) && + !strcmp(url,"/tor/post/consensus-signature")) { /* sigs on consensus. */ + if (dirvote_add_signatures(body)>=0) { + write_http_status_line(conn, 200, "Signatures stored"); + } else { + write_http_status_line(conn, 400, "Unable to store signatures"); + } + goto done; + } + /* we didn't recognize the url */ write_http_status_line(conn, 404, "Not found"); diff --git a/src/or/or.h b/src/or/or.h index 4a466648b9..039fa052e5 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -375,10 +375,12 @@ typedef enum { #define DIR_PURPOSE_UPLOAD_VOTE 10 /** A connection to a directory server: fetch a v3 networkstatus vote. */ #define DIR_PURPOSE_FETCH_VOTE 11 +/** A connection to a directory server: upload a v3 consensus signature */ +#define DIR_PURPOSE_UPLOAD_SIGNATURES 12 /** Purpose for connection at a directory server. */ -#define DIR_PURPOSE_SERVER 12 -#define _DIR_PURPOSE_MAX 12 +#define DIR_PURPOSE_SERVER 13 +#define _DIR_PURPOSE_MAX 13 #define _EXIT_PURPOSE_MIN 1 /** This exit stream wants to do an ordinary connect. */ |