summaryrefslogtreecommitdiff
path: root/src/common/tortls.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-06-22 15:29:30 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-11 16:13:17 -0400
commit734d9486f62b0fb19c71cac7a484ae65091bd41d (patch)
tree1b42bcc91ce3062fb0e4f6c0d3c4a94fea4c8077 /src/common/tortls.c
parent0fd8ce15c2d970368d1ccf5f77a4e407a008a76d (diff)
downloadtor-734d9486f62b0fb19c71cac7a484ae65091bd41d.tar.gz
tor-734d9486f62b0fb19c71cac7a484ae65091bd41d.zip
Record the states of failing OR connections
This code lets us record the state of any outgoing OR connection that fails before it becomes open, so we can notice if they're all dying in the same SSL state or the same OR handshake state. More work is still needed: - We need documentation - We need to actually call the code that reports the failure when we realize that we're having a hard time connecting out or making circuits. - We need to periodically clear out all this data -- perhaps, whenever we build a circuit successfully? - We'll eventually want to expose it to controllers, perhaps. Partial implementation of feature 3116.
Diffstat (limited to 'src/common/tortls.c')
-rw-r--r--src/common/tortls.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 94ca81ba49..8db47a6f21 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -222,6 +222,37 @@ ssl_state_to_string(int ssl_state)
return buf;
}
+/** DOCDOC 3116 */
+void
+tor_tls_get_state_description(tor_tls_t *tls, char *buf, size_t sz)
+{
+ const char *ssl_state;
+ const char *tortls_state;
+
+ if (PREDICT_UNLIKELY(!tls || !tls->ssl)) {
+ strlcpy(buf, "(No SSL object)", sz);
+ return;
+ }
+
+ ssl_state = ssl_state_to_string(tls->ssl->state);
+ switch (tls->state) {
+#define CASE(st) case TOR_TLS_ST_##st: tortls_state = #st ; break
+ CASE(HANDSHAKE);
+ CASE(OPEN);
+ CASE(GOTCLOSE);
+ CASE(SENTCLOSE);
+ CASE(CLOSED);
+ CASE(RENEGOTIATE);
+ CASE(BUFFEREVENT);
+#undef CASE
+ default:
+ tortls_state = "unknown";
+ break;
+ }
+
+ tor_snprintf(buf, sz, "%s in %s", ssl_state, tortls_state);
+}
+
void
tor_tls_log_one_error(tor_tls_t *tls, unsigned long err,
int severity, int domain, const char *doing)