summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-05-27 21:02:36 +0000
committerNick Mathewson <nickm@torproject.org>2008-05-27 21:02:36 +0000
commit4ea2a4595e0331db531d293315be58a21394bd1f (patch)
tree8dc1a80c21832823ada2fb5b7d71431e6a57cc44
parent9975c4f6f8c54b150335a5cd6bb7e0e7defbca80 (diff)
downloadtor-4ea2a4595e0331db531d293315be58a21394bd1f.tar.gz
tor-4ea2a4595e0331db531d293315be58a21394bd1f.zip
Fix the first part of bug 681, as suggested by Robert Hogan on or-talk.
svn:r14754
-rw-r--r--ChangeLog2
-rw-r--r--doc/spec/control-spec.txt10
-rw-r--r--src/or/control.c25
-rw-r--r--src/or/or.h6
4 files changed, 41 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 29b0160fc1..15cd5883d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -98,6 +98,8 @@ Changes in version 0.2.1.1-alpha - 2008-??-??
patch to their OpenSSL, turn it on to save memory on servers. This
patch will (with any luck) get included in a mainline distribution
before too long.
+ - Add a "PURPOSE=" argument to "STREAM NEW" events, as suggested by
+ Robert Hogan. Fixes the first part of bug 681.
o Minor features (security):
- Reject requests for reverse-dns lookup of names in a private
diff --git a/doc/spec/control-spec.txt b/doc/spec/control-spec.txt
index bba15659f6..da149c602c 100644
--- a/doc/spec/control-spec.txt
+++ b/doc/spec/control-spec.txt
@@ -988,6 +988,7 @@ $Id$
"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 =
@@ -1037,6 +1038,15 @@ $Id$
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:
diff --git a/src/or/control.c b/src/or/control.c
index 01d5918112..878f0d2f01 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -3108,6 +3108,7 @@ control_event_stream_status(edge_connection_t *conn, stream_status_event_t tp,
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))
@@ -3175,15 +3176,35 @@ control_event_stream_status(edge_connection_t *conn, stream_status_event_t tp,
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? */
diff --git a/src/or/or.h b/src/or/or.h
index 624d407d4c..2ebe7511db 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -369,6 +369,12 @@ typedef enum {
#define DIR_PURPOSE_FETCH_RENDDESC_V2 18
#define _DIR_PURPOSE_MAX 18
+#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_SIGNATURES)
+
#define _EXIT_PURPOSE_MIN 1
/** This exit stream wants to do an ordinary connect. */
#define EXIT_PURPOSE_CONNECT 1