r13463@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.)


svn:r10639
This commit is contained in:
Nick Mathewson 2007-06-17 15:10:51 +00:00
parent c9c9bdfc1d
commit d828915136
3 changed files with 25 additions and 4 deletions

View File

@ -10,6 +10,10 @@ Changes in version 0.2.0.3-alpha - 2007-??-??
- 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.

View File

@ -835,7 +835,8 @@ $Id$
"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 @@ $Id$
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:

View File

@ -425,7 +425,7 @@ get_escaped_string(const char *start, size_t in_len_max,
* 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 @@ control_event_stream_status(edge_connection_t *conn, stream_status_event_t tp,
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 @@ control_event_stream_status(edge_connection_t *conn, stream_status_event_t tp,
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;