summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-11-17 03:34:58 +0000
committerNick Mathewson <nickm@torproject.org>2006-11-17 03:34:58 +0000
commite2abc727e5ee08037eb79615ca81d52f6d14ef07 (patch)
tree1fe26481a4c26bda3437a36214bf169d18611cc8
parentd125c61e02743d5420567f954a176baeaa4f76a9 (diff)
downloadtor-e2abc727e5ee08037eb79615ca81d52f6d14ef07.tar.gz
tor-e2abc727e5ee08037eb79615ca81d52f6d14ef07.zip
r9561@Kushana: nickm | 2006-11-16 22:32:54 -0500
Tweaks to test-connection patch: use ".noconnect" instead of ".test" (since there are lots of ways to test things). Use a regular sequence of STREAM events (NEW followed by CLOSED) instead of a new event type. Make the function that checks the address be static and use const and strcasecmpend properly. svn:r8959
-rw-r--r--ChangeLog6
-rw-r--r--doc/TODO2
-rw-r--r--src/or/connection_edge.c27
-rw-r--r--src/or/control.c16
-rw-r--r--src/or/or.h6
5 files changed, 25 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 417b2a356f..3db6081bc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,12 @@ Changes in version 0.1.2.4-alpha - 2006-11-??
o Minor features
- Add breakdown of public key operations to dumped statistics.
+ o Minor features, controller
+ - Make all connections to addresses of the form .noconnect immediately
+ get closed. This is more useful than you'd think, since it lets
+ application/controller combos successfully tell when they're talking to
+ the same Tor by watching for STREAM events.
+
o Major bugfixes
- Handle TransPort connections even when the server sends data before
the client sends data. Previously, the connection would just hang
diff --git a/doc/TODO b/doc/TODO
index 1d4b8367a1..c22533424b 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -57,6 +57,8 @@ N . Have (and document) a BEGIN_DIR relay cell that means "Connect to your
- Use for something, so we can be sure it works.
- Test and debug
+N - Document .noconnect addresses... but where?
+
o Send back RELAY_END cells on malformed RELAY_BEGIN.
o Change the circuit end reason display a little for reasons from
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 6d3b482d6d..ada9a4a400 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -30,6 +30,7 @@ static smartlist_t *redirect_exit_list = NULL;
static int connection_ap_handshake_process_socks(edge_connection_t *conn);
static int connection_ap_process_natd(edge_connection_t *conn);
static int connection_exit_connect_dir(edge_connection_t *exit_conn);
+static int hostname_is_noconnect_address(const char *address);
/** An AP stream has failed/finished. If it hasn't already sent back
* a socks reply, send one now (based on endreason). Also set
@@ -1395,8 +1396,8 @@ connection_ap_get_original_destination(edge_connection_t *conn,
* If the handshake is complete, send it to
* connection_ap_handshake_rewrite_and_attach().
*
- * Return -1 if an unexpected error with conn (and it should be marked
- * for close), else return 0.
+ * Return -1 if an unexpected error with conn ocurrs (and mark it for close),
+ * else return 0.
*/
static int
connection_ap_handshake_process_socks(edge_connection_t *conn)
@@ -1440,10 +1441,11 @@ connection_ap_handshake_process_socks(edge_connection_t *conn)
return -1;
} /* else socks handshake is done, continue processing */
- if (hostname_is_a_test_address(socks->address))
+ if (hostname_is_noconnect_address(socks->address))
{
- control_event_teststream(conn);
- connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
+ control_event_stream_status(conn, STREAM_EVENT_NEW, 0);
+ control_event_stream_status(conn, STREAM_EVENT_CLOSED, 0);
+ connection_mark_unattached_ap(conn, END_STREAM_REASON_DONE);
return -1;
}
@@ -2457,16 +2459,11 @@ failed:
return BAD_HOSTNAME;
}
-/** Check if the address is of the form "y.test"
+/** Check if the address is of the form "y.noconnect"
*/
-int
-hostname_is_a_test_address(char *address)
+static int
+hostname_is_noconnect_address(const char *address)
{
- char *s;
- s = strrchr(address,'.');
- if (!s)
- return 0;
- if (!strcmp(s+1,"test"))
- return 1;
- return 0;
+ return ! strcasecmpend(address, ".noconnect");
}
+
diff --git a/src/or/control.c b/src/or/control.c
index 76724be0d7..9470e49e0d 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -86,8 +86,7 @@ const char control_c_id[] =
#define EVENT_STATUS_CLIENT 0x0010
#define EVENT_STATUS_SERVER 0x0011
#define EVENT_STATUS_GENERAL 0x0012
-#define EVENT_TESTSTREAM 0x0013
-#define _EVENT_MAX 0x0013
+#define _EVENT_MAX 0x0012
/* If _EVENT_MAX ever hits 0x0020, we need to make the mask wider. */
/** Array mapping from message type codes to human-readable message
@@ -1064,8 +1063,6 @@ handle_control_setevents(control_connection_t *conn, uint32_t len,
event_code = EVENT_STATUS_CLIENT;
else if (!strcasecmp(ev, "STATUS_SERVER"))
event_code = EVENT_STATUS_SERVER;
- else if (!strcasecmp(ev, "TESTSTREAM"))
- event_code = EVENT_TESTSTREAM;
else {
connection_printf_to_buf(conn, "552 Unrecognized event \"%s\"\r\n",
ev);
@@ -3547,17 +3544,6 @@ control_event_server_status(int severity, const char *format, ...)
return r;
}
-/** Called when a request is made for a hostname ending in .test
- */
-int
-control_event_teststream(edge_connection_t *conn)
-{
- send_control1_event(EVENT_TESTSTREAM, ALL_NAMES|ALL_FORMATS,
- "650 TESTSTREAM %s\r\n",
- conn->socks_request->address);
- return 0;
-}
-
/** Choose a random authentication cookie and write it to disk.
* Anybody who can read the cookie from disk will be considered
* authorized to use the control connection. */
diff --git a/src/or/or.h b/src/or/or.h
index afe91a8326..07baf6b294 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -473,6 +473,8 @@ typedef enum {
* everywhere. */
#define END_STREAM_REASON_FIXME_XXXX 0
+/* Reasons why we (or a remote OR) might close a stream. See tor-spec.txt for
+ * documentation of these. */
#define END_STREAM_REASON_MISC 1
#define END_STREAM_REASON_RESOLVEFAILED 2
#define END_STREAM_REASON_CONNECTREFUSED 3
@@ -514,6 +516,8 @@ typedef enum {
#define END_CIRC_REASON_NOPATH -2
#define END_CIRC_AT_ORIGIN -1
+/* Reasons why we (or a remote OR) might close a circuit. See tor-spec.txt for
+ * documentation of these. */
#define _END_CIRC_REASON_MIN 0
#define END_CIRC_REASON_NONE 0
#define END_CIRC_REASON_TORPROTOCOL 1
@@ -2034,7 +2038,6 @@ typedef enum hostname_type_t {
NORMAL_HOSTNAME, ONION_HOSTNAME, EXIT_HOSTNAME, BAD_HOSTNAME
} hostname_type_t;
hostname_type_t parse_extended_hostname(char *address);
-int hostname_is_a_test_address(char *address);
/********************************* connection_or.c ***************************/
@@ -2142,7 +2145,6 @@ int control_event_client_status(int severity, const char *format, ...)
CHECK_PRINTF(2,3);
int control_event_server_status(int severity, const char *format, ...)
CHECK_PRINTF(2,3);
-int control_event_teststream(edge_connection_t *conn);
int init_cookie_authentication(int enabled);
int decode_hashed_password(char *buf, const char *hashed);