r13963@catbus: nickm | 2007-07-28 22:53:32 -0400

Add support for signature upload


svn:r10962
This commit is contained in:
Nick Mathewson 2007-07-29 02:55:21 +00:00
parent 9895d840f5
commit d2adb68ed6
3 changed files with 56 additions and 9 deletions

View File

@ -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.

View File

@ -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");

View File

@ -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. */