diff options
author | Roger Dingledine <arma@torproject.org> | 2005-08-15 03:25:40 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-08-15 03:25:40 +0000 |
commit | f57d062d9c4fed001bb6dcd40d122de8d1368e0a (patch) | |
tree | b06b9db856e88ec49fc62b819d1c671474b75bfa /src/or/connection_edge.c | |
parent | 121ea4dd933b78b77189823557a5728a736a9a2f (diff) | |
download | tor-f57d062d9c4fed001bb6dcd40d122de8d1368e0a.tar tor-f57d062d9c4fed001bb6dcd40d122de8d1368e0a.tar.gz |
Implement exit enclaves: if we know an IP address for the destination,
and there's a running Tor server at that address which allows exit to
the destination, then extend the circuit to that exit first.
Also, if the user asks for a .exit node, cannibalize general circs for it.
svn:r4779
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r-- | src/or/connection_edge.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index edd776b86..e2f1d43b5 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -1009,7 +1009,7 @@ connection_ap_handshake_process_socks(connection_t *conn) return -1; } if (tor_inet_aton(socks->address, &in)) { /* see if it's an IP already */ - answer = in.s_addr; + answer = in.s_addr; /* leave it in network order */ connection_ap_handshake_socks_resolved(conn,RESOLVED_TYPE_IPV4,4, (char*)&answer); connection_mark_unattached_ap(conn, END_STREAM_REASON_ALREADY_SOCKS_REPLIED); @@ -1023,20 +1023,34 @@ connection_ap_handshake_process_socks(connection_t *conn) connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL); return -1; } + + if (!conn->chosen_exit_name) { + /* see if we can find a suitable enclave exit */ + routerinfo_t *r = + router_find_exact_exit_enclave(socks->address, socks->port); + if (r) { + log_fn(LOG_INFO,"Redirecting address %s to exit at enclave router %s", + safe_str(socks->address), r->nickname); + /* use the hex digest, not nickname, in case there are two + routers with this nickname */ + conn->chosen_exit_name = + tor_strdup(hex_str(r->identity_digest, DIGEST_LEN)); + } + } + rep_hist_note_used_port(socks->port, time(NULL)); /* help predict this next time */ control_event_stream_status(conn, STREAM_EVENT_NEW); } - if (! get_options()->LeaveStreamsUnattached) { + if (get_options()->LeaveStreamsUnattached) { + conn->state = AP_CONN_STATE_CONTROLLER_WAIT; + } else { conn->state = AP_CONN_STATE_CIRCUIT_WAIT; if (connection_ap_handshake_attach_circuit(conn) < 0) { connection_mark_unattached_ap(conn, END_STREAM_REASON_CANT_ATTACH); return -1; } - return 0; - } else { - conn->state = AP_CONN_STATE_CONTROLLER_WAIT; - return 0; } + return 0; } else { /* it's a hidden-service request */ rend_cache_entry_t *entry; |