summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-09-26 18:58:45 +0000
committerNick Mathewson <nickm@torproject.org>2008-09-26 18:58:45 +0000
commite147e867bea13515c964e823e3f98c28f90cf22c (patch)
treea8af8f882985c2edfa36f1eee2e44de17a6a4a80 /src/or/control.c
parent87eb230c01693c0cdb81d05a6bd2c866874c5e3a (diff)
downloadtor-e147e867bea13515c964e823e3f98c28f90cf22c.tar.gz
tor-e147e867bea13515c964e823e3f98c28f90cf22c.zip
Proposal 152 implementation from Josh Albrecht, with tweaks.
svn:r16983
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 93a946405d..8ae93e4998 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2324,11 +2324,26 @@ handle_control_attachstream(control_connection_t *conn, uint32_t len,
conn);
return 0;
}
+ /* Is this a single hop circuit? */
if (circ && (circuit_get_cpath_len(circ)<2 || hop==1)) {
- connection_write_str_to_buf(
- "551 Can't attach stream to one-hop circuit.\r\n", conn);
- return 0;
+ routerinfo_t *r = NULL;
+ char* exit_digest;
+ if (circ->build_state &&
+ circ->build_state->chosen_exit &&
+ circ->build_state->chosen_exit->identity_digest) {
+ exit_digest = circ->build_state->chosen_exit->identity_digest;
+ r = router_get_by_digest(exit_digest);
+ }
+ /* Do both the client and relay allow one-hop exit circuits? */
+ if (!r || !r->allow_single_hop_exits ||
+ !get_options()->AllowSingleHopCircuits) {
+ connection_write_str_to_buf(
+ "551 Can't attach stream to this one-hop circuit.\r\n", conn);
+ return 0;
+ }
+ ap_conn->chosen_exit_name = tor_strdup(hex_str(exit_digest, DIGEST_LEN));
}
+
if (circ && hop>0) {
/* find this hop in the circuit, and set cpath */
cpath = circuit_get_cpath_hop(circ, hop);