summaryrefslogtreecommitdiff
path: root/src/or/circuituse.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-12-13 00:28:56 +0000
committerRoger Dingledine <arma@torproject.org>2006-12-13 00:28:56 +0000
commit0dbf725927c0b3a7f88b852b272573c91857be9b (patch)
treebea851e8726f18a8b463f950bfc1694ae6be6aa2 /src/or/circuituse.c
parentf5164ba61d8cf062bbc1beb2dfbca0abb3415e93 (diff)
downloadtor-0dbf725927c0b3a7f88b852b272573c91857be9b.tar.gz
tor-0dbf725927c0b3a7f88b852b272573c91857be9b.zip
Infrastructure to test BEGIN_DIR cells.
New socks command CONNECT_DIR. New config option TunnelDirConns that builds a circ ending at the directory server and delivers a BEGIN_DIR cell if it's running 0.1.2.2-alpha or later. We still need to make one-hop circs when appropriate, while making other conns avoid them. svn:r9098
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r--src/or/circuituse.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index dd56c4621a..d5f5fce265 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -902,16 +902,18 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
origin_circuit_t **circp)
{
origin_circuit_t *circ;
- int is_resolve;
+ int check_exit_policy;
int need_uptime, need_internal;
tor_assert(conn);
tor_assert(circp);
tor_assert(conn->_base.state == AP_CONN_STATE_CIRCUIT_WAIT);
- is_resolve = (conn->socks_request->command == SOCKS_COMMAND_RESOLVE ||
- conn->socks_request->command == SOCKS_COMMAND_RESOLVE_PTR);
+ check_exit_policy =
+ (conn->socks_request->command == SOCKS_COMMAND_CONNECT) &&
+ !connection_edge_is_rendezvous_stream(conn);
- need_uptime = smartlist_string_num_isin(get_options()->LongLivedPorts,
+ need_uptime = (conn->socks_request->command == SOCKS_COMMAND_CONNECT) &&
+ smartlist_string_num_isin(get_options()->LongLivedPorts,
conn->socks_request->port);
need_internal = desired_circuit_purpose != CIRCUIT_PURPOSE_C_GENERAL;
@@ -941,7 +943,7 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
}
/* Do we need to check exit policy? */
- if (!is_resolve && !connection_edge_is_rendezvous_stream(conn)) {
+ if (check_exit_policy) {
struct in_addr in;
uint32_t addr = 0;
if (tor_inet_aton(conn->socks_request->address, &in))
@@ -1125,13 +1127,17 @@ connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn,
link_apconn_to_circ(conn, circ);
tor_assert(conn->socks_request);
- if (conn->socks_request->command == SOCKS_COMMAND_CONNECT) {
- consider_recording_trackhost(conn, circ);
- if (connection_ap_handshake_send_begin(conn, circ)<0)
- return -1;
- } else {
- if (connection_ap_handshake_send_resolve(conn, circ)<0)
- return -1;
+ switch (conn->socks_request->command) {
+ case SOCKS_COMMAND_CONNECT:
+ consider_recording_trackhost(conn, circ);
+ /* fall through */
+ case SOCKS_COMMAND_CONNECT_DIR:
+ if (connection_ap_handshake_send_begin(conn, circ)<0)
+ return -1;
+ break;
+ default:
+ if (connection_ap_handshake_send_resolve(conn, circ)<0)
+ return -1;
}
return 1;