Loading doc/control-spec.txt +13 −1 Original line number Diff line number Diff line Loading @@ -885,7 +885,8 @@ $Id$ 4.1.3. OR Connection status changed The syntax is: "650" SP "ORCONN" SP (ServerID / Target) SP ORStatus "650" SP "ORCONN" SP (ServerID / Target) SP ORStatus [ SP "REASON=" Reason ] [ SP "NCIRCS=" NumCircuits ] ORStatus = "NEW" / "LAUNCHED" / "CONNECTED" / "FAILED" / "CLOSED" Loading @@ -898,6 +899,17 @@ $Id$ A ServerID is specified unless it's a NEW connection, in which case we don't know what server it is yet, so we use Address:Port. If extended events are enabled (see 3.19), optional reason and circuit counting information is provided for CLOSED and FAILED events. Reason = "MISC" / "DONE" / "CONNECTREFUSED" / "IDENTITY" / "CONNECTRESET" / "TIMEOUT" / "NOROUTE" / "IOERROR" NumCircuits counts both established and pending circuits. 4.1.4. Bandwidth used in the last second The syntax is: Loading src/common/tortls.c +45 −9 Original line number Diff line number Diff line Loading @@ -73,8 +73,8 @@ static tor_tls_context_t *global_tls_context = NULL; static int tls_library_is_initialized = 0; /* Module-internal error codes. */ #define _TOR_TLS_SYSCALL -6 #define _TOR_TLS_ZERORETURN -5 #define _TOR_TLS_SYSCALL -10 #define _TOR_TLS_ZERORETURN -9 /* These functions are declared in crypto.c but not exported. */ EVP_PKEY *_crypto_pk_env_get_evp_pkey(crypto_pk_env_t *env, int private); Loading Loading @@ -103,6 +103,39 @@ tls_log_errors(int severity, const char *doing) } } static int tor_errno_to_tls_error(int e) { #if defined(MS_WINDOWS) && !defined(USE_BSOCKETS) switch(e) { case WSAECONNRESET: // most common return TOR_TLS_ERROR_CONNRESET; case WSAETIMEDOUT: return TOR_TLS_ERROR_TIMEOUT; case WSAENETUNREACH: case WSAEHOSTUNREACH: return TOR_TLS_ERROR_NO_ROUTE; case WSAECONNREFUSED: return TOR_TLS_ERROR_CONNREFUSED; // least common default: return TOR_TLS_ERROR_MISC; } #else switch(e) { case ECONNRESET: // most common return TOR_TLS_ERROR_CONNRESET; case ETIMEDOUT: return TOR_TLS_ERROR_TIMEOUT; case EHOSTUNREACH: case ENETUNREACH: return TOR_TLS_ERROR_NO_ROUTE; case ECONNREFUSED: return TOR_TLS_ERROR_CONNREFUSED; // least common default: return TOR_TLS_ERROR_MISC; } #endif } #define CATCH_SYSCALL 1 #define CATCH_ZERO 2 Loading @@ -121,6 +154,7 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra, const char *doing, int severity) { int err = SSL_get_error(tls->ssl, r); int tor_error = TOR_TLS_ERROR_MISC; switch (err) { case SSL_ERROR_NONE: return TOR_TLS_DONE; Loading @@ -131,25 +165,27 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra, case SSL_ERROR_SYSCALL: if (extra&CATCH_SYSCALL) return _TOR_TLS_SYSCALL; if (r == 0) if (r == 0) { log(severity, LD_NET, "TLS error: unexpected close while %s", doing); else { tor_error = TOR_TLS_ERROR_IO; } else { int e = tor_socket_errno(tls->socket); log(severity, LD_NET, "TLS error: <syscall error while %s> (errno=%d: %s)", doing, e, tor_socket_strerror(e)); tor_error = tor_errno_to_tls_error(e); } tls_log_errors(severity, doing); return TOR_TLS_ERROR; return tor_error; case SSL_ERROR_ZERO_RETURN: if (extra&CATCH_ZERO) return _TOR_TLS_ZERORETURN; log(severity, LD_NET, "TLS error: Zero return"); tls_log_errors(severity, doing); return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; default: tls_log_errors(severity, doing); return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; } } Loading Loading @@ -547,7 +583,7 @@ tor_tls_handshake(tor_tls_t *tls) if (ERR_peek_error() != 0) { tls_log_errors(tls->isServer ? LOG_INFO : LOG_WARN, "handshaking"); return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; } if (r == TOR_TLS_DONE) { tls->state = TOR_TLS_ST_OPEN; Loading Loading @@ -607,7 +643,7 @@ tor_tls_shutdown(tor_tls_t *tls) tls->state == TOR_TLS_ST_SENTCLOSE) { log(LOG_WARN, LD_NET, "TLS returned \"half-closed\" value while already half-closed"); return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; } tls->state = TOR_TLS_ST_SENTCLOSE; /* fall through ... */ Loading src/common/tortls.h +10 −5 Original line number Diff line number Diff line Loading @@ -19,7 +19,12 @@ typedef struct tor_tls_t tor_tls_t; /* Possible return values for most tor_tls_* functions. */ #define TOR_TLS_ERROR -4 #define TOR_TLS_ERROR_MISC -9 #define TOR_TLS_ERROR_IO -8 #define TOR_TLS_ERROR_CONNREFUSED -7 #define TOR_TLS_ERROR_CONNRESET -6 #define TOR_TLS_ERROR_NO_ROUTE -5 #define TOR_TLS_ERROR_TIMEOUT -4 #define TOR_TLS_CLOSE -3 #define TOR_TLS_WANTREAD -2 #define TOR_TLS_WANTWRITE -1 Loading src/or/buffers.c +1 −1 Original line number Diff line number Diff line Loading @@ -543,7 +543,7 @@ read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf) (int)at_most); if (buf_ensure_capacity(buf, at_most+buf->datalen)) return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; if (at_most + buf->datalen > buf->len) at_most = buf->len - buf->datalen; Loading src/or/circuitbuild.c +2 −1 Original line number Diff line number Diff line Loading @@ -897,7 +897,8 @@ circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer) * means that a connection broke or an extend failed. For now, * just give up. */ circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_OR_CONN_CLOSED); circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_FLAG_REMOTE|END_CIRC_REASON_OR_CONN_CLOSED); return 0; #if 0 Loading Loading
doc/control-spec.txt +13 −1 Original line number Diff line number Diff line Loading @@ -885,7 +885,8 @@ $Id$ 4.1.3. OR Connection status changed The syntax is: "650" SP "ORCONN" SP (ServerID / Target) SP ORStatus "650" SP "ORCONN" SP (ServerID / Target) SP ORStatus [ SP "REASON=" Reason ] [ SP "NCIRCS=" NumCircuits ] ORStatus = "NEW" / "LAUNCHED" / "CONNECTED" / "FAILED" / "CLOSED" Loading @@ -898,6 +899,17 @@ $Id$ A ServerID is specified unless it's a NEW connection, in which case we don't know what server it is yet, so we use Address:Port. If extended events are enabled (see 3.19), optional reason and circuit counting information is provided for CLOSED and FAILED events. Reason = "MISC" / "DONE" / "CONNECTREFUSED" / "IDENTITY" / "CONNECTRESET" / "TIMEOUT" / "NOROUTE" / "IOERROR" NumCircuits counts both established and pending circuits. 4.1.4. Bandwidth used in the last second The syntax is: Loading
src/common/tortls.c +45 −9 Original line number Diff line number Diff line Loading @@ -73,8 +73,8 @@ static tor_tls_context_t *global_tls_context = NULL; static int tls_library_is_initialized = 0; /* Module-internal error codes. */ #define _TOR_TLS_SYSCALL -6 #define _TOR_TLS_ZERORETURN -5 #define _TOR_TLS_SYSCALL -10 #define _TOR_TLS_ZERORETURN -9 /* These functions are declared in crypto.c but not exported. */ EVP_PKEY *_crypto_pk_env_get_evp_pkey(crypto_pk_env_t *env, int private); Loading Loading @@ -103,6 +103,39 @@ tls_log_errors(int severity, const char *doing) } } static int tor_errno_to_tls_error(int e) { #if defined(MS_WINDOWS) && !defined(USE_BSOCKETS) switch(e) { case WSAECONNRESET: // most common return TOR_TLS_ERROR_CONNRESET; case WSAETIMEDOUT: return TOR_TLS_ERROR_TIMEOUT; case WSAENETUNREACH: case WSAEHOSTUNREACH: return TOR_TLS_ERROR_NO_ROUTE; case WSAECONNREFUSED: return TOR_TLS_ERROR_CONNREFUSED; // least common default: return TOR_TLS_ERROR_MISC; } #else switch(e) { case ECONNRESET: // most common return TOR_TLS_ERROR_CONNRESET; case ETIMEDOUT: return TOR_TLS_ERROR_TIMEOUT; case EHOSTUNREACH: case ENETUNREACH: return TOR_TLS_ERROR_NO_ROUTE; case ECONNREFUSED: return TOR_TLS_ERROR_CONNREFUSED; // least common default: return TOR_TLS_ERROR_MISC; } #endif } #define CATCH_SYSCALL 1 #define CATCH_ZERO 2 Loading @@ -121,6 +154,7 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra, const char *doing, int severity) { int err = SSL_get_error(tls->ssl, r); int tor_error = TOR_TLS_ERROR_MISC; switch (err) { case SSL_ERROR_NONE: return TOR_TLS_DONE; Loading @@ -131,25 +165,27 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra, case SSL_ERROR_SYSCALL: if (extra&CATCH_SYSCALL) return _TOR_TLS_SYSCALL; if (r == 0) if (r == 0) { log(severity, LD_NET, "TLS error: unexpected close while %s", doing); else { tor_error = TOR_TLS_ERROR_IO; } else { int e = tor_socket_errno(tls->socket); log(severity, LD_NET, "TLS error: <syscall error while %s> (errno=%d: %s)", doing, e, tor_socket_strerror(e)); tor_error = tor_errno_to_tls_error(e); } tls_log_errors(severity, doing); return TOR_TLS_ERROR; return tor_error; case SSL_ERROR_ZERO_RETURN: if (extra&CATCH_ZERO) return _TOR_TLS_ZERORETURN; log(severity, LD_NET, "TLS error: Zero return"); tls_log_errors(severity, doing); return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; default: tls_log_errors(severity, doing); return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; } } Loading Loading @@ -547,7 +583,7 @@ tor_tls_handshake(tor_tls_t *tls) if (ERR_peek_error() != 0) { tls_log_errors(tls->isServer ? LOG_INFO : LOG_WARN, "handshaking"); return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; } if (r == TOR_TLS_DONE) { tls->state = TOR_TLS_ST_OPEN; Loading Loading @@ -607,7 +643,7 @@ tor_tls_shutdown(tor_tls_t *tls) tls->state == TOR_TLS_ST_SENTCLOSE) { log(LOG_WARN, LD_NET, "TLS returned \"half-closed\" value while already half-closed"); return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; } tls->state = TOR_TLS_ST_SENTCLOSE; /* fall through ... */ Loading
src/common/tortls.h +10 −5 Original line number Diff line number Diff line Loading @@ -19,7 +19,12 @@ typedef struct tor_tls_t tor_tls_t; /* Possible return values for most tor_tls_* functions. */ #define TOR_TLS_ERROR -4 #define TOR_TLS_ERROR_MISC -9 #define TOR_TLS_ERROR_IO -8 #define TOR_TLS_ERROR_CONNREFUSED -7 #define TOR_TLS_ERROR_CONNRESET -6 #define TOR_TLS_ERROR_NO_ROUTE -5 #define TOR_TLS_ERROR_TIMEOUT -4 #define TOR_TLS_CLOSE -3 #define TOR_TLS_WANTREAD -2 #define TOR_TLS_WANTWRITE -1 Loading
src/or/buffers.c +1 −1 Original line number Diff line number Diff line Loading @@ -543,7 +543,7 @@ read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf) (int)at_most); if (buf_ensure_capacity(buf, at_most+buf->datalen)) return TOR_TLS_ERROR; return TOR_TLS_ERROR_MISC; if (at_most + buf->datalen > buf->len) at_most = buf->len - buf->datalen; Loading
src/or/circuitbuild.c +2 −1 Original line number Diff line number Diff line Loading @@ -897,7 +897,8 @@ circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer) * means that a connection broke or an extend failed. For now, * just give up. */ circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_OR_CONN_CLOSED); circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_FLAG_REMOTE|END_CIRC_REASON_OR_CONN_CLOSED); return 0; #if 0 Loading