diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-11-03 18:33:07 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-11-03 18:33:07 +0000 |
commit | 451f8b50452ae44c4319cfe55c666a45b9994e9f (patch) | |
tree | d88f565d8f7f74253af9d2a721978737b157782a /src/or/circuitbuild.c | |
parent | 86ba00290b4e1f7095c1d34c46ac5b61273953be (diff) | |
download | tor-451f8b50452ae44c4319cfe55c666a45b9994e9f.tar.gz tor-451f8b50452ae44c4319cfe55c666a45b9994e9f.zip |
- Implement all of control interface except authentication, setconfig,
and actually making the sockets.
- Make sure that identity-based nicknames start with $.
- Use new string_join interface.
svn:r2661
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r-- | src/or/circuitbuild.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index f163abe2be..170cde8c23 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -63,6 +63,40 @@ static uint16_t get_unique_circ_id_by_conn(connection_t *conn, int circ_id_type) return test_circ_id; } +/** Allocate and return a comma-separated list of the currently built + * elements of circuit_t. + */ +char *circuit_list_path(circuit_t *circ) +{ + struct crypt_path_t *hop; + routerinfo_t *r; + smartlist_t *elements; + char *s; + tor_assert(CIRCUIT_IS_ORIGIN(circ)); + tor_assert(circ->cpath); + + elements = smartlist_create(); + + for (hop = circ->cpath; hop; hop = hop->next) { + if (hop->state != CPATH_STATE_OPEN) + break; + if ((r = router_get_by_digest(hop->identity_digest))) { + smartlist_add(elements, tor_strdup(r->nickname)); + } else if (circ->purpose == CIRCUIT_PURPOSE_C_REND_JOINED) { + smartlist_add(elements, tor_strdup("<rendezvous splice>")); + } else { + s = tor_malloc(HEX_DIGEST_LEN+2); + s[0]='$'; + base16_encode(s+1,HEX_DIGEST_LEN+1,hop->identity_digest,DIGEST_LEN); + smartlist_add(elements, s); + } + } + + s = smartlist_join_strings(elements, ",", 0, NULL); + SMARTLIST_FOREACH(elements, char*, cp, tor_free(cp)); + return s; +} + /** Log, at severity <b>severity</b>, the nicknames of each router in * circ's cpath. Also log the length of the cpath, and the intended * exit point. @@ -220,6 +254,8 @@ circuit_t *circuit_establish_circuit(uint8_t purpose, return NULL; } + control_event_circuit_status(circ, CIRC_EVENT_LAUNCHED); + /* now see if we're already connected to the first OR in 'route' */ tor_assert(firsthop); @@ -604,6 +640,8 @@ int circuit_finish_handshake(circuit_t *circ, char *reply) { hop->state = CPATH_STATE_OPEN; log_fn(LOG_INFO,"finished"); circuit_log_path(LOG_INFO,circ); + control_event_circuit_status(circ, CIRC_EVENT_EXTENDED); + return 0; } |