[or-cvs] r14755: Backport: Fix the first part of bug 681, as suggested by Rob (in tor/branches/tor-0_2_0-patches: . doc/spec src/or)
nickm at seul.org
nickm at seul.org
Tue May 27 21:02:50 UTC 2008
Author: nickm
Date: 2008-05-27 17:02:49 -0400 (Tue, 27 May 2008)
New Revision: 14755
Modified:
tor/branches/tor-0_2_0-patches/ChangeLog
tor/branches/tor-0_2_0-patches/doc/spec/control-spec.txt
tor/branches/tor-0_2_0-patches/src/or/control.c
tor/branches/tor-0_2_0-patches/src/or/or.h
Log:
Backport: Fix the first part of bug 681, as suggested by Robert Hogan on or-talk.
Modified: tor/branches/tor-0_2_0-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_2_0-patches/ChangeLog 2008-05-27 21:02:36 UTC (rev 14754)
+++ tor/branches/tor-0_2_0-patches/ChangeLog 2008-05-27 21:02:49 UTC (rev 14755)
@@ -1,4 +1,8 @@
Changes in version 0.2.0.27-rc - 2008-05-??
+ o Minor features (controller):
+ - Add a "PURPOSE=" argument to "STREAM NEW" events, as suggested by
+ Robert Hogan. Fixes the first part of bug 681.
+
o Minor bugfixes (controller):
- When tunneling an encrypted directory connection, and its first circuit
fails do not leave it unattached and ask the controller to deal. Fixes
Modified: tor/branches/tor-0_2_0-patches/doc/spec/control-spec.txt
===================================================================
--- tor/branches/tor-0_2_0-patches/doc/spec/control-spec.txt 2008-05-27 21:02:36 UTC (rev 14754)
+++ tor/branches/tor-0_2_0-patches/doc/spec/control-spec.txt 2008-05-27 21:02:49 UTC (rev 14755)
@@ -984,6 +984,7 @@
"650" SP "STREAM" SP StreamID SP StreamStatus SP CircID SP Target
[SP "REASON=" Reason [ SP "REMOTE_REASON=" Reason ]]
[SP "SOURCE=" Source] [ SP "SOURCE_ADDR=" Address ":" Port ]
+ [SP "PURPOSE=" Purpose]
CRLF
StreamStatus =
@@ -1033,6 +1034,13 @@
that requested the connection, and can be (e.g.) used to look up the
requesting program.
+ Purpose = "DIR_FETCH" / "UPLOAD_DESC" / "DNS_REQUEST" /
+ "USER" / "DIRPORT_TEST"
+
+ The "PURPOSE" field is provided only for NEW and NEWRESOLVE events, and
+ only if extended events are enabled (see 3.19). Clients MUST accept
+ purposes not listed above.
+
4.1.3. OR Connection status changed
The syntax is:
Modified: tor/branches/tor-0_2_0-patches/src/or/control.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/control.c 2008-05-27 21:02:36 UTC (rev 14754)
+++ tor/branches/tor-0_2_0-patches/src/or/control.c 2008-05-27 21:02:49 UTC (rev 14755)
@@ -3048,6 +3048,7 @@
circuit_t *circ;
origin_circuit_t *origin_circ = NULL;
char buf[256];
+ const char *purpose = "";
tor_assert(conn->socks_request);
if (!EVENT_IS_INTERESTING(EVENT_STREAM_STATUS))
@@ -3115,15 +3116,35 @@
addrport_buf[0] = '\0';
}
+ if (tp == STREAM_EVENT_NEW_RESOLVE) {
+ purpose = " PURPOSE=DNS_REQUEST";
+ } else if (tp == STREAM_EVENT_NEW) {
+ if (conn->is_dns_request ||
+ (conn->socks_request &&
+ SOCKS_COMMAND_IS_RESOLVE(conn->socks_request->command)))
+ purpose = " PURPOSE=DNS_REQUEST";
+ else if (conn->use_begindir) {
+ connection_t *linked = TO_CONN(conn)->linked_conn;
+ int linked_dir_purpose = -1;
+ if (linked && linked->type == CONN_TYPE_DIR)
+ linked_dir_purpose = linked->purpose;
+ if (DIR_PURPOSE_IS_UPLOAD(linked_dir_purpose))
+ purpose = " PURPOSE=DIR_UPLOAD";
+ else
+ purpose = " PURPOSE=DIR_FETCH";
+ } else
+ purpose = " PURPOSE=USER";
+ }
+
circ = circuit_get_by_edge_conn(conn);
if (circ && CIRCUIT_IS_ORIGIN(circ))
origin_circ = TO_ORIGIN_CIRCUIT(circ);
send_control_event_extended(EVENT_STREAM_STATUS, ALL_NAMES,
- "650 STREAM %lu %s %lu %s@%s%s\r\n",
+ "650 STREAM %lu %s %lu %s@%s%s%s\r\n",
(unsigned long)conn->global_identifier, status,
origin_circ?
(unsigned long)origin_circ->global_identifier : 0ul,
- buf, reason_buf, addrport_buf);
+ buf, reason_buf, addrport_buf, purpose);
/* XXX need to specify its intended exit, etc? */
Modified: tor/branches/tor-0_2_0-patches/src/or/or.h
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/or.h 2008-05-27 21:02:36 UTC (rev 14754)
+++ tor/branches/tor-0_2_0-patches/src/or/or.h 2008-05-27 21:02:49 UTC (rev 14755)
@@ -371,8 +371,8 @@
#define DIR_PURPOSE_IS_UPLOAD(p) \
((p)==DIR_PURPOSE_UPLOAD_DIR || \
- (p)==DIR_PURPOSE_UPLOAD_RENDDESC || \
- (p)==DIR_PURPOSE_UPLOAD_VOTE || \
+ (p)==DIR_PURPOSE_UPLOAD_RENDDESC || \
+ (p)==DIR_PURPOSE_UPLOAD_VOTE || \
(p)==DIR_PURPOSE_UPLOAD_SIGNATURES)
#define _EXIT_PURPOSE_MIN 1
More information about the tor-commits
mailing list