[or-cvs] r10962: Add support for signature upload (in tor/trunk: . doc src/or)
nickm at seul.org
nickm at seul.org
Sun Jul 29 02:55:22 UTC 2007
Author: nickm
Date: 2007-07-28 22:55:21 -0400 (Sat, 28 Jul 2007)
New Revision: 10962
Modified:
tor/trunk/
tor/trunk/doc/TODO
tor/trunk/src/or/directory.c
tor/trunk/src/or/or.h
Log:
r13963 at catbus: nickm | 2007-07-28 22:53:32 -0400
Add support for signature upload
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r13963] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO 2007-07-29 01:18:00 UTC (rev 10961)
+++ tor/trunk/doc/TODO 2007-07-29 02:55:21 UTC (rev 10962)
@@ -94,7 +94,7 @@
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 @@
- 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.
Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c 2007-07-29 01:18:00 UTC (rev 10961)
+++ tor/trunk/src/or/directory.c 2007-07-29 02:55:21 UTC (rev 10962)
@@ -80,6 +80,7 @@
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 @@
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 @@
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 @@
}
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 @@
* 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 @@
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");
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2007-07-29 01:18:00 UTC (rev 10961)
+++ tor/trunk/src/or/or.h 2007-07-29 02:55:21 UTC (rev 10962)
@@ -375,10 +375,12 @@
#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. */
More information about the tor-commits
mailing list