summaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-06-15 06:01:04 +0000
committerRoger Dingledine <arma@torproject.org>2007-06-15 06:01:04 +0000
commit2cd293dc8f447d9b96590c92d2ef00458c3996a2 (patch)
treee154736479ba230f7ee09deb8ba5ffa04d59cdad /src/or/circuitbuild.c
parent6a2f045163e7583fd41318cd8f0e4d321c937fee (diff)
downloadtor-2cd293dc8f447d9b96590c92d2ef00458c3996a2.tar.gz
tor-2cd293dc8f447d9b96590c92d2ef00458c3996a2.zip
now we can specify a bridge without specifying its key,
and we will still connect to it and use it. getting closer! svn:r10609
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index f505ae03fe..3f8515542e 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -413,13 +413,23 @@ circuit_n_conn_done(or_connection_t *or_conn, int status)
SMARTLIST_FOREACH(pending_circs, circuit_t *, circ,
{
- /* This check is redundant wrt get_all_pending_on_or_conn, but I'm
+ /* These checks are redundant wrt get_all_pending_on_or_conn, but I'm
* leaving them in in case it's possible for the status of a circuit to
* change as we're going down the list. */
if (circ->marked_for_close || circ->n_conn ||
- circ->state != CIRCUIT_STATE_OR_WAIT ||
- memcmp(or_conn->identity_digest, circ->n_conn_id_digest, DIGEST_LEN))
+ circ->state != CIRCUIT_STATE_OR_WAIT)
continue;
+ if (tor_digest_is_zero(circ->n_conn_id_digest)) {
+ /* Look at addr/port. This is an unkeyed connection. */
+ if (circ->n_addr != or_conn->_base.addr ||
+ circ->n_port != or_conn->_base.port)
+ continue;
+ } else {
+ /* We expected a key. See if it's the right one. */
+ if (memcmp(or_conn->identity_digest,
+ circ->n_conn_id_digest, DIGEST_LEN))
+ continue;
+ }
if (!status) { /* or_conn failed; close circ */
log_info(LD_CIRC,"or_conn failed. Closing circ.");
circuit_mark_for_close(circ, END_CIRC_REASON_OR_CONN_CLOSED);
@@ -2670,6 +2680,7 @@ clear_bridge_list(void)
smartlist_clear(bridge_list);
}
+#if 0
/** Return 1 if <b>digest</b> is one of our known bridges. */
int
identity_digest_is_a_bridge(const char *digest)
@@ -2681,6 +2692,24 @@ identity_digest_is_a_bridge(const char *digest)
});
return 0;
}
+#endif
+
+/** Return 1 if <b>ri</b> is one of our known bridges (either by
+ * comparing keys if possible, else by comparing addr/port). */
+int
+routerinfo_is_a_bridge(routerinfo_t *ri)
+{
+ SMARTLIST_FOREACH(bridge_list, bridge_info_t *, bridge,
+ {
+ if (tor_digest_is_zero(bridge->identity) &&
+ bridge->addr == ri->addr && bridge->port == ri->or_port)
+ return 1;
+ if (!memcmp(bridge->identity, ri->cache_info.identity_digest,
+ DIGEST_LEN))
+ return 1;
+ });
+ return 0;
+}
/** Remember a new bridge at <b>addr</b>:<b>port</b>. If <b>digest</b>
* is set, it tells us the identity key too. */