Resolve a FIXME: use identity comparison, not nickname comparison, to

choose circuit ID types.  This is important because our view of "the
nickname of the router on the other side of this connection" is
skewed, and depends on whether we think the other rotuer is
verified--and there's no way to know whether another router thinks you
are verified.

For backward compatibility, we notice when the other router chooses
the same circuit ID type as us (because it's running an old version),
and switch our type to be polite.


svn:r2797
This commit is contained in:
Nick Mathewson
2004-11-10 20:14:37 +00:00
parent 35d0d3c050
commit 954570486f
5 changed files with 48 additions and 37 deletions
+16
View File
@@ -139,6 +139,22 @@ static void command_process_create_cell(cell_t *cell, connection_t *conn) {
return;
}
/* If the high bit of the circuit ID is not as expected, then switch
* which half of the space we'll use for our own CREATE cells.
*
* This can happen because Tor 0.0.9pre5 and earlier decide which
* half to use based on nickname, and we now use identity keys.
*/
if ((cell->circ_id & (1<<15)) && conn->circ_id_type == CIRC_ID_TYPE_HIGHER) {
log_fn(LOG_INFO, "Got a high circuit ID from %s (%d); switching to low circuit IDs.",
conn->nickname, conn->s);
conn->circ_id_type = CIRC_ID_TYPE_LOWER;
} else if (!(cell->circ_id & (1<<15)) && conn->circ_id_type == CIRC_ID_TYPE_LOWER) {
log_fn(LOG_INFO, "Got a low circuit ID from %s (%d); switching to high circuit IDs.",
conn->nickname, conn->s);
conn->circ_id_type = CIRC_ID_TYPE_HIGHER;
}
circ = circuit_new(cell->circ_id, conn);
circ->state = CIRCUIT_STATE_ONIONSKIN_PENDING;
circ->purpose = CIRCUIT_PURPOSE_OR;