[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r14446: and the client part of the consensus-by-authority-fpr propos (tor/trunk/src/or)
Author: weasel
Date: 2008-04-24 11:38:57 -0400 (Thu, 24 Apr 2008)
New Revision: 14446
Modified:
tor/trunk/src/or/circuitbuild.c
tor/trunk/src/or/directory.c
tor/trunk/src/or/networkstatus.c
tor/trunk/src/or/or.h
tor/trunk/src/or/router.c
tor/trunk/src/or/routerlist.c
tor/trunk/src/or/routerparse.c
Log:
and the client part of the consensus-by-authority-fpr proposal (ifdef'ed out)
Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c 2008-04-24 15:38:54 UTC (rev 14445)
+++ tor/trunk/src/or/circuitbuild.c 2008-04-24 15:38:57 UTC (rev 14446)
@@ -2924,6 +2924,7 @@
return; /* it's already on the way */
directory_initiate_command(address, bridge->addr,
bridge->port, 0,
+ 0, /* does not matter */
1, bridge->identity,
DIR_PURPOSE_FETCH_SERVERDESC,
ROUTER_PURPOSE_BRIDGE,
Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c 2008-04-24 15:38:54 UTC (rev 14445)
+++ tor/trunk/src/or/directory.c 2008-04-24 15:38:57 UTC (rev 14446)
@@ -37,6 +37,7 @@
static void directory_send_command(dir_connection_t *conn,
int purpose, int direct, const char *resource,
const char *payload, size_t payload_len,
+ int supports_conditional_consensus,
time_t if_modified_since);
static int directory_handle_command(dir_connection_t *conn);
static int body_is_plausible(const char *body, size_t body_len, int purpose);
@@ -339,10 +340,13 @@
/* want to ask a running bridge for which we have a descriptor. */
/* XXX021 we assume that all of our bridges can answer any
* possible directory question. This won't be true forever. -RD */
+ /* It certainly is not true with conditional consensus downloading,
+ * so, for now, never assume the server supports that. */
routerinfo_t *ri = choose_random_entry(NULL);
if (ri) {
directory_initiate_command(ri->address, ri->addr,
ri->or_port, 0,
+ 0, /* don't use conditional consensus url */
1, ri->cache_info.identity_digest,
dir_purpose,
router_purpose,
@@ -464,6 +468,7 @@
}
directory_initiate_command(address, status->addr,
status->or_port, status->dir_port,
+ status->version_supports_conditional_consensus,
status->version_supports_begindir,
status->identity_digest,
dir_purpose, router_purpose,
@@ -645,6 +650,7 @@
void
directory_initiate_command(const char *address, uint32_t addr,
uint16_t or_port, uint16_t dir_port,
+ int supports_conditional_consensus,
int supports_begindir, const char *digest,
uint8_t dir_purpose, uint8_t router_purpose,
int anonymized_connection, const char *resource,
@@ -707,7 +713,9 @@
case 0:
/* queue the command on the outbuf */
directory_send_command(conn, dir_purpose, 1, resource,
- payload, payload_len, if_modified_since);
+ payload, payload_len,
+ supports_conditional_consensus,
+ if_modified_since);
connection_watch_events(TO_CONN(conn), EV_READ | EV_WRITE);
/* writable indicates finish, readable indicates broken link,
error indicates broken link in windowsland. */
@@ -744,7 +752,9 @@
conn->_base.state = DIR_CONN_STATE_CLIENT_SENDING;
/* queue the command on the outbuf */
directory_send_command(conn, dir_purpose, 0, resource,
- payload, payload_len, if_modified_since);
+ payload, payload_len,
+ supports_conditional_consensus,
+ if_modified_since);
connection_watch_events(TO_CONN(conn), EV_READ | EV_WRITE);
connection_start_reading(TO_CONN(linked_conn));
}
@@ -763,6 +773,55 @@
return TO_CONN(conn)->linked;
}
+/** Return the URL we should use for a consensus download.
+ *
+ * This url depends on whether or not the server we go to
+ * is sufficiently new to support conditional consensus downloading,
+ * i.e. GET .../consensus/<fpr>+<fpr>+<fpr>
+ */
+#define CONDITIONAL_CONSENSUS_FPR_LEN 3
+#if (CONDITIONAL_CONSENSUS_FPR_LEN > DIGEST_LEN)
+#error "conditional consensus fingerprint length is larger than digest length
+#endif
+static char *
+directory_get_consensus_url(int supports_conditional_consensus)
+{
+ char *url;
+ int len;
+
+#ifndef SUPPORTS_CONDITIONAL_CONSENSUS_SINCE_VERSION
+ supports_conditional_consensus = 0;
+#endif
+
+ if (supports_conditional_consensus) {
+ char *authority_id_list;
+ smartlist_t *authority_digets = smartlist_create();
+
+ SMARTLIST_FOREACH(router_get_trusted_dir_servers(),
+ trusted_dir_server_t *, ds,
+ {
+ char *hex = tor_malloc(2*CONDITIONAL_CONSENSUS_FPR_LEN+1);
+ base16_encode(hex, 2*CONDITIONAL_CONSENSUS_FPR_LEN+1,
+ ds->digest, CONDITIONAL_CONSENSUS_FPR_LEN);
+ smartlist_add(authority_digets, hex);
+ });
+ authority_id_list = smartlist_join_strings(authority_digets,
+ "+", 0, NULL);
+
+ len = strlen(authority_id_list)+64;
+ url = tor_malloc(len);
+ tor_snprintf(url, len, "/tor/status-vote/current/consensus/%s.z",
+ authority_id_list);
+
+ SMARTLIST_FOREACH(authority_digets, char *, cp, tor_free(cp));
+ smartlist_free(authority_digets);
+ tor_free(authority_id_list);
+ } else {
+ url = tor_strdup("/tor/status-vote/current/consensus.z");
+ }
+ return url;
+}
+
/** Queue an appropriate HTTP command on conn-\>outbuf. The other args
* are as in directory_initiate_command.
*/
@@ -770,6 +829,7 @@
directory_send_command(dir_connection_t *conn,
int purpose, int direct, const char *resource,
const char *payload, size_t payload_len,
+ int supports_conditional_consensus,
time_t if_modified_since)
{
char proxystring[256];
@@ -852,7 +912,10 @@
tor_assert(!resource);
tor_assert(!payload);
httpcommand = "GET";
- url = tor_strdup("/tor/status-vote/current/consensus.z");
+ url = directory_get_consensus_url(supports_conditional_consensus);
+ /* XXX021: downgrade/remove once done with conditional consensus fu */
+ log_notice(LD_DIR, "Downloading consensus from %s using %s",
+ hoststring, url);
break;
case DIR_PURPOSE_FETCH_CERTIFICATE:
tor_assert(resource);
Modified: tor/trunk/src/or/networkstatus.c
===================================================================
--- tor/trunk/src/or/networkstatus.c 2008-04-24 15:38:54 UTC (rev 14445)
+++ tor/trunk/src/or/networkstatus.c 2008-04-24 15:38:57 UTC (rev 14446)
@@ -1280,6 +1280,8 @@
a->version_supports_begindir != b->version_supports_begindir ||
a->version_supports_extrainfo_upload !=
b->version_supports_extrainfo_upload ||
+ a->version_supports_conditional_consensus !=
+ b->version_supports_conditional_consensus ||
a->version_supports_v3_dir != b->version_supports_v3_dir;
}
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2008-04-24 15:38:54 UTC (rev 14445)
+++ tor/trunk/src/or/or.h 2008-04-24 15:38:57 UTC (rev 14446)
@@ -709,6 +709,11 @@
/** Largest number of bytes that can fit in a relay cell payload. */
#define RELAY_PAYLOAD_SIZE (CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE)
+/** Version that started supporting conditional consensus downloading
+ * as a dirserver. This define can go once we know the answer and
+ * want to use the feature. */
+// #define SUPPORTS_CONDITIONAL_CONSENSUS_SINCE_VERSION "0.2.1.1"
+
/** Parsed onion routing cell. All communication between nodes
* is via cells. */
typedef struct cell_t {
@@ -1369,6 +1374,9 @@
unsigned int version_known:1;
/** True iff this router is a version that supports BEGIN_DIR cells. */
unsigned int version_supports_begindir:1;
+ /** True iff this router is a version that supports conditional consensus
+ * downloads (signed by list of authorities). */
+ unsigned int version_supports_conditional_consensus:1;
/** True iff this router is a version that we can post extrainfo docs to. */
unsigned int version_supports_extrainfo_upload:1;
/** True iff this router is a version that, if it caches directory info,
@@ -3048,6 +3056,7 @@
void connection_dir_request_failed(dir_connection_t *conn);
void directory_initiate_command(const char *address, uint32_t addr,
uint16_t or_port, uint16_t dir_port,
+ int supports_conditional_consensus,
int supports_begindir, const char *digest,
uint8_t dir_purpose, uint8_t router_purpose,
int anonymized_connection,
Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c 2008-04-24 15:38:54 UTC (rev 14445)
+++ tor/trunk/src/or/router.c 2008-04-24 15:38:57 UTC (rev 14446)
@@ -726,6 +726,7 @@
/* ask myself, via tor, for my server descriptor. */
directory_initiate_command(me->address, me->addr,
me->or_port, me->dir_port,
+ 0, /* does not matter */
0, me->cache_info.identity_digest,
DIR_PURPOSE_FETCH_SERVERDESC,
ROUTER_PURPOSE_GENERAL,
Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c 2008-04-24 15:38:54 UTC (rev 14445)
+++ tor/trunk/src/or/routerlist.c 2008-04-24 15:38:57 UTC (rev 14446)
@@ -3512,6 +3512,7 @@
if (ent->or_port)
ent->fake_status.version_supports_begindir = 1;
+ ent->fake_status.version_supports_conditional_consensus = 1;
smartlist_add(trusted_dir_servers, ent);
router_dir_info_changed();
Modified: tor/trunk/src/or/routerparse.c
===================================================================
--- tor/trunk/src/or/routerparse.c 2008-04-24 15:38:54 UTC (rev 14445)
+++ tor/trunk/src/or/routerparse.c 2008-04-24 15:38:57 UTC (rev 14446)
@@ -1828,6 +1828,7 @@
if (strcmpstart(tok->args[0], "Tor ")) {
rs->version_supports_begindir = 1;
rs->version_supports_extrainfo_upload = 1;
+ rs->version_supports_conditional_consensus = 1;
} else {
rs->version_supports_begindir =
tor_version_as_new_as(tok->args[0], "0.2.0.1-alpha");
@@ -1835,6 +1836,13 @@
tor_version_as_new_as(tok->args[0], "0.2.0.0-alpha-dev (r10070)");
rs->version_supports_v3_dir =
tor_version_as_new_as(tok->args[0], "0.2.0.8-alpha");
+#ifdef SUPPORTS_CONDITIONAL_CONSENSUS_SINCE_VERSION
+ rs->version_supports_conditional_consensus =
+ tor_version_as_new_as(tok->args[0],
+ SUPPORTS_CONDITIONAL_CONSENSUS_SINCE_VERSION);
+#else
+ rs->version_supports_conditional_consensus = 0;
+#endif
}
if (vote_rs) {
vote_rs->version = tor_strdup(tok->args[0]);