aboutsummaryrefslogtreecommitdiff
path: root/src/or/channeltls.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@persephoneslair.org>2012-09-13 02:44:21 -0700
committerAndrea Shepard <andrea@torproject.org>2012-10-08 03:06:09 -0700
commit7138a4adac9592edbb73d3983cc51db153c76edf (patch)
treef0314640762ef7ed2a3975bff8bae5226629e2f2 /src/or/channeltls.c
parenta9a75ee59a719f938b02d48c6df3db649cf32cb9 (diff)
downloadtor-7138a4adac9592edbb73d3983cc51db153c76edf.tar
tor-7138a4adac9592edbb73d3983cc51db153c76edf.tar.gz
Keep better statistics about channels and dump them from dumpstats() on SIGUSR1
Diffstat (limited to 'src/or/channeltls.c')
-rw-r--r--src/or/channeltls.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/or/channeltls.c b/src/or/channeltls.c
index 352037c14..8a1b5ebc9 100644
--- a/src/or/channeltls.c
+++ b/src/or/channeltls.c
@@ -47,6 +47,7 @@ channel_tls_t *channel_tls_listener = NULL;
/* channel_tls_t method declarations */
static void channel_tls_close_method(channel_t *chan);
+static const char * channel_tls_describe_transport_method(channel_t *chan);
static int
channel_tls_get_remote_addr_method(channel_t *chan, tor_addr_t *addr_out);
static const char *
@@ -104,6 +105,7 @@ channel_tls_connect(const tor_addr_t *addr, uint16_t port,
channel_init_for_cells(chan);
chan->state = CHANNEL_STATE_OPENING;
chan->close = channel_tls_close_method;
+ chan->describe_transport = channel_tls_describe_transport_method;
chan->u.cell_chan.get_remote_addr = channel_tls_get_remote_addr_method;
chan->u.cell_chan.get_remote_descr = channel_tls_get_remote_descr_method;
chan->u.cell_chan.has_queued_writes = channel_tls_has_queued_writes_method;
@@ -188,12 +190,15 @@ channel_tls_start_listener(void)
channel_init_listener(lchan);
lchan->state = CHANNEL_STATE_LISTENING;
lchan->close = channel_tls_close_method;
+ lchan->describe_transport = channel_tls_describe_transport_method;
channel_tls_listener = listener;
log_debug(LD_CHANNEL,
"Starting TLS listener channel %p with global id %lu",
lchan, lchan->global_identifier);
+
+ channel_register(lchan);
} else lchan = TLS_CHAN_TO_BASE(channel_tls_listener);
return lchan;
@@ -245,6 +250,7 @@ channel_tls_handle_incoming(or_connection_t *orconn)
channel_init_for_cells(chan);
chan->state = CHANNEL_STATE_OPENING;
chan->close = channel_tls_close_method;
+ chan->describe_transport = channel_tls_describe_transport_method;
chan->u.cell_chan.get_remote_descr = channel_tls_get_remote_descr_method;
chan->u.cell_chan.has_queued_writes = channel_tls_has_queued_writes_method;
chan->u.cell_chan.is_canonical = channel_tls_is_canonical_method;
@@ -335,6 +341,43 @@ channel_tls_close_method(channel_t *chan)
}
/**
+ * Describe the transport for a channel_tls_t
+ *
+ * This returns the string "TLS channel on connection <id>" to the upper
+ * layer.
+ */
+
+static const char *
+channel_tls_describe_transport_method(channel_t *chan)
+{
+ static char *buf = NULL;
+ uint64_t id;
+ channel_tls_t *tlschan;
+ const char *rv = NULL;
+
+ tor_assert(chan);
+
+ if (chan->is_listener) {
+ rv = "TLS channel (listening)";
+ } else {
+ tlschan = BASE_CHAN_TO_TLS(chan);
+
+ if (tlschan->conn) {
+ id = TO_CONN(tlschan->conn)->global_identifier;
+
+ if (buf) tor_free(buf);
+ tor_asprintf(&buf, "TLS channel (connection %lu)", id);
+
+ rv = buf;
+ } else {
+ rv = "TLS channel (no connection)";
+ }
+ }
+
+ return rv;
+}
+
+/**
* Get the remote address of a channel_tls_t
*
* This implements the get_remote_addr method for channel_tls_t; copy the