summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-07-29 02:55:21 +0000
committerNick Mathewson <nickm@torproject.org>2007-07-29 02:55:21 +0000
commitd2adb68ed63eebfa8ec3fb58cc28e6428418427f (patch)
tree05c9361d86ee0c4729928b94561cd30acf294ff8
parent9895d840f597f1a781f79caf7b44760499a22c66 (diff)
downloadtor-d2adb68ed63eebfa8ec3fb58cc28e6428418427f.tar.gz
tor-d2adb68ed63eebfa8ec3fb58cc28e6428418427f.zip
r13963@catbus: nickm | 2007-07-28 22:53:32 -0400
Add support for signature upload svn:r10962
-rw-r--r--doc/TODO13
-rw-r--r--src/or/directory.c46
-rw-r--r--src/or/or.h6
3 files changed, 56 insertions, 9 deletions
diff --git a/doc/TODO b/doc/TODO
index ccc327637d..9d98ad9d4d 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -94,7 +94,7 @@ Things we'd like to do in 0.2.0.x:
o Forget ones that are very old.
- Download as needed.
o Actually invoke trusted_dirs_flush_certs_to_disk()
- * Serve list as needed.
+ - Serve list as needed.
* Detect whether votes are really all for the same period.
o Avoid double-checking signatures every time we get a vote.
- Warn about expired stuff.
@@ -107,12 +107,13 @@ Things we'd like to do in 0.2.0.x:
- Push/pull documents as appropriate.
. Push vote on voting
o Push vote
- * Process vote when received
- * Even if we get it before we start voting ourself.
+ o Process vote when received
+ o Even if we get it before we start voting ourself.
* Push signature on forming consensus.
- * Push signature
- * Add signatures when received
- * Queue received signatures before consensus is ready
+ o Push signature
+ o Add signatures when received
+ o Queue received signatures before consensus is ready
+ * When consensus is ready, use queued signatures.
- Pull votes and signatures if we don't get them.
* Serve and store consensuses.
- Cache votes and signatures on disk.
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. */