[or-cvs] r8958: Check in an implementation of "test" connections from Scott (in tor/trunk: . src/or)
nickm at seul.org
nickm at seul.org
Fri Nov 17 03:34:48 UTC 2006
Author: nickm
Date: 2006-11-16 22:34:44 -0500 (Thu, 16 Nov 2006)
New Revision: 8958
Modified:
tor/trunk/
tor/trunk/src/or/connection_edge.c
tor/trunk/src/or/control.c
tor/trunk/src/or/or.h
Log:
r9560 at Kushana: nickm | 2006-11-16 22:09:12 -0500
Check in an implementation of "test" connections from Scott Squires:
these connections immediately close upon reaching Tor. They're useful
for apps that want to check whether they're talking to the same Tor as
a given controller. (I'll be tweaking this a bit before I push.)
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r9560] on c95137ef-5f19-0410-b913-86e773d04f59
Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c 2006-11-16 19:32:26 UTC (rev 8957)
+++ tor/trunk/src/or/connection_edge.c 2006-11-17 03:34:44 UTC (rev 8958)
@@ -1440,6 +1440,13 @@
return -1;
} /* else socks handshake is done, continue processing */
+ if (hostname_is_a_test_address(socks->address))
+ {
+ control_event_teststream(conn);
+ connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
+ return -1;
+ }
+
if (socks->command == SOCKS_COMMAND_CONNECT)
control_event_stream_status(conn, STREAM_EVENT_NEW, 0);
else
@@ -2450,3 +2457,16 @@
return BAD_HOSTNAME;
}
+/** Check if the address is of the form "y.test"
+ */
+int
+hostname_is_a_test_address(char *address)
+{
+ char *s;
+ s = strrchr(address,'.');
+ if (!s)
+ return 0;
+ if (!strcmp(s+1,"test"))
+ return 1;
+ return 0;
+}
Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c 2006-11-16 19:32:26 UTC (rev 8957)
+++ tor/trunk/src/or/control.c 2006-11-17 03:34:44 UTC (rev 8958)
@@ -86,7 +86,8 @@
#define EVENT_STATUS_CLIENT 0x0010
#define EVENT_STATUS_SERVER 0x0011
#define EVENT_STATUS_GENERAL 0x0012
-#define _EVENT_MAX 0x0012
+#define EVENT_TESTSTREAM 0x0013
+#define _EVENT_MAX 0x0013
/* If _EVENT_MAX ever hits 0x0020, we need to make the mask wider. */
/** Array mapping from message type codes to human-readable message
@@ -1063,6 +1064,8 @@
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);
@@ -3544,6 +3547,17 @@
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. */
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2006-11-16 19:32:26 UTC (rev 8957)
+++ tor/trunk/src/or/or.h 2006-11-17 03:34:44 UTC (rev 8958)
@@ -2034,6 +2034,7 @@
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 ***************************/
@@ -2141,6 +2142,7 @@
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);
More information about the tor-commits
mailing list