[or-cvs] r10639: Add a SOURCE_ADDR field to STREAM NEW events so that control (in tor/trunk: . doc/spec src/or)

nickm at seul.org nickm at seul.org
Sun Jun 17 15:10:51 UTC 2007


Author: nickm
Date: 2007-06-17 11:10:51 -0400 (Sun, 17 Jun 2007)
New Revision: 10639

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/spec/control-spec.txt
   tor/trunk/src/or/control.c
Log:
 r13463 at catbus:  nickm | 2007-06-17 11:10:17 -0400
 Add a SOURCE_ADDR field to STREAM NEW events so that controllers can match requests to applications. (Patch from Robert Hogan.)



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13463] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-06-17 15:10:46 UTC (rev 10638)
+++ tor/trunk/ChangeLog	2007-06-17 15:10:51 UTC (rev 10639)
@@ -10,6 +10,10 @@
     - Fail quickly and (relatively) harmlessly if we generate a network
       status document that is somehow malformed.
 
+  o Minor features (controller):
+    - Add a SOURCE_ADDR field to STREAM NEW events so that controllers can
+      match requests to applications. (Patch from Robert Hogan.)
+
   o Deprecated features:
     - RedirectExits is now deprecated.
 

Modified: tor/trunk/doc/spec/control-spec.txt
===================================================================
--- tor/trunk/doc/spec/control-spec.txt	2007-06-17 15:10:46 UTC (rev 10638)
+++ tor/trunk/doc/spec/control-spec.txt	2007-06-17 15:10:51 UTC (rev 10639)
@@ -835,7 +835,8 @@
 
       "650" SP "STREAM" SP StreamID SP StreamStatus SP CircID SP Target
           [SP "REASON=" Reason [ SP "REMOTE_REASON=" Reason ]]
-          [SP "SOURCE=" Source] CRLF
+          [SP "SOURCE=" Source] [ SP "SOURCE_ADDR=" Address ":" Port ]
+          CRLF
 
       StreamStatus =
                "NEW"          / ; New request to connect
@@ -879,6 +880,11 @@
    answer, and "EXIT" is given if the remote node we queried gave us
    the new address as a response.
 
+   The "SOURCE_ADDR" field is included with NEW and NEWRESOLVE events if
+   extended events are enabled.  It indicates the address that requested
+   the connection, and can be (e.g.) used to look up the requesting
+   program.
+
 4.1.3. OR Connection status changed
 
   The syntax is:

Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c	2007-06-17 15:10:46 UTC (rev 10638)
+++ tor/trunk/src/or/control.c	2007-06-17 15:10:51 UTC (rev 10639)
@@ -425,7 +425,7 @@
  * but it will always end with a CRLF sequence.
  *
  * Currently the length of the message is limited to 1024 (including the
- * ending \n\r\0. */
+ * ending \r\n\0. */
 static void
 connection_printf_to_buf(control_connection_t *conn, const char *format, ...)
 {
@@ -2636,6 +2636,7 @@
                             int reason_code)
 {
   char reason_buf[64];
+  char addrport_buf[64];
   const char *status;
   circuit_t *circ;
   origin_circuit_t *origin_circ = NULL;
@@ -2698,15 +2699,25 @@
       break;
     }
   }
+
+  if (tp == STREAM_EVENT_NEW) {
+    tor_snprintf(addrport_buf,sizeof(addrport_buf), "%sSOURCE_ADDR=%s:%d",
+                 strlen(reason_buf) ? " " : "",
+                 TO_CONN(conn)->address, TO_CONN(conn)->port );
+  } else {
+    addrport_buf[0] = '\0';
+  }
+
   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\r\n",
+                        "650 STREAM %lu %s %lu %s@%s%s\r\n",
                         (unsigned long)conn->global_identifier, status,
                         origin_circ?
                            (unsigned long)origin_circ->global_identifier : 0ul,
-                        buf, reason_buf);
+                        buf, reason_buf, addrport_buf);
+
   /* XXX need to specify its intended exit, etc? */
 
   return 0;



More information about the tor-commits mailing list