mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Unify tests for "did I originate this nonopen OR connection?"
svn:r2468
This commit is contained in:
parent
30dd1c87a5
commit
e0cce8fba8
@ -192,13 +192,7 @@ void connection_about_to_close_connection(connection_t *conn)
|
||||
case CONN_TYPE_OR:
|
||||
/* Remember why we're closing this connection. */
|
||||
if (conn->state != OR_CONN_STATE_OPEN) {
|
||||
/* XXX Nick: this still isn't right, because it might be
|
||||
* dying even though we didn't initiate the connect. Can
|
||||
* you look at this more? -RD XXXX008 -NM*/
|
||||
/* XXX We only set conn->nickname when we initiate the connection, or
|
||||
* when the handshake is complete; so conn->nickname is a good test
|
||||
* for "we initiated the connection", right? -NM */
|
||||
if(conn->nickname)
|
||||
if(connection_or_nonopen_was_started_here(conn))
|
||||
rep_hist_note_connect_failed(conn->identity_digest, time(NULL));
|
||||
} else if (0) { // XXX reason == CLOSE_REASON_UNUSED_OR_CONN) {
|
||||
rep_hist_note_disconnect(conn->identity_digest, time(NULL));
|
||||
|
@ -300,10 +300,17 @@ int connection_tls_continue_handshake(connection_t *conn) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int digest_is_zero(const char *id) {
|
||||
char ZERO_DIGEST[DIGEST_LEN];
|
||||
memset(ZERO_DIGEST, 0, DIGEST_LEN);
|
||||
return !memcmp(ZERO_DIGEST, id, DIGEST_LEN);
|
||||
static char ZERO_DIGEST[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
|
||||
|
||||
int connection_or_nonopen_was_started_here(connection_t *conn)
|
||||
{
|
||||
tor_assert(sizeof(ZERO_DIGEST) == DIGEST_LEN);
|
||||
tor_assert(conn->type == CONN_TYPE_OR);
|
||||
|
||||
if (!memcmp(ZERO_DIGEST, conn->identity_digest, DIGEST_LEN))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** The tls handshake is finished.
|
||||
@ -371,7 +378,7 @@ connection_tls_finish_handshake(connection_t *conn) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!digest_is_zero(conn->identity_digest)) {
|
||||
if (connection_or_nonopen_was_started_here(conn)) {
|
||||
/* I initiated this connection. */
|
||||
if (strcasecmp(conn->nickname, nickname)) {
|
||||
log_fn(options.DirPort ? LOG_WARN : LOG_INFO,
|
||||
|
@ -1110,6 +1110,7 @@ int connection_state_is_connecting(connection_t *conn);
|
||||
int connection_send_destroy(uint16_t circ_id, connection_t *conn);
|
||||
|
||||
void assert_connection_ok(connection_t *conn, time_t now);
|
||||
int connection_or_nonopen_was_started_here(connection_t *conn);
|
||||
|
||||
/********************************* connection_edge.c ***************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user