Improve conn_*_to_string; add circuit_state_to_string; make skewed-descriptor messages better.

svn:r4047
This commit is contained in:
Nick Mathewson 2005-04-07 21:07:19 +00:00
parent dd98412ce1
commit 8cc3307e0d
7 changed files with 27 additions and 15 deletions

View file

@ -185,7 +185,7 @@ circuit_dump_details(int severity, circuit_t *circ, int poll_index,
const char *type, int this_circid, int other_circid) {
log(severity,"Conn %d has %s circuit: circID %d (other side %d), state %d (%s), born %d:",
poll_index, type, this_circid, other_circid, circ->state,
circuit_state_to_string[circ->state], (int)circ->timestamp_created);
circuit_state_to_string(circ->state), (int)circ->timestamp_created);
if (CIRCUIT_IS_ORIGIN(circ)) { /* circ starts at this node */
circuit_log_path(severity, circ);
}

View file

@ -15,14 +15,6 @@ const char circuitlist_c_id[] = "$Id$";
/********* START VARIABLES **********/
/** Array of strings to make circ-\>state human-readable */
const char *circuit_state_to_string[] = {
"doing handshakes", /* 0 */
"processing the onion", /* 1 */
"connecting to firsthop", /* 2 */
"open" /* 3 */
};
/** A global list of all circuits at this hop. */
circuit_t *global_circuitlist=NULL;
@ -156,6 +148,22 @@ void circuit_close_all_marked(void)
}
}
/** Function to make circ-\>state human-readable */
const char *
circuit_state_to_string(int state) {
static buf[64];
switch (state) {
case CIRCUIT_STATE_BUILDING: return "doing handshakes";
case CIRCUIT_STATE_ONIONSKIN_PENDING: return "processing the onion";
case CIRCUIT_STATE_OR_WAIT: return "connecting to firsthop";
case CIRCUIT_STATE_OPEN: return "open";
default:
log_fn(LOG_WARN, "Bug: unknown circuit state %d", state);
tor_snprintf(buf, sizeof(buf), "unknown state [%d], state");
return buf;
}
}
/** Allocate space for a new circuit, initializing with <b>p_circ_id</b>
* and <b>p_conn</b>. Add it to the global circuit list.
*/

View file

@ -240,10 +240,10 @@ void circuit_expire_building(time_t now) {
if (victim->n_conn)
log_fn(LOG_INFO,"Abandoning circ %s:%d:%d (state %d:%s, purpose %d)",
victim->n_conn->address, victim->n_port, victim->n_circ_id,
victim->state, circuit_state_to_string[victim->state], victim->purpose);
victim->state, circuit_state_to_string(victim->state), victim->purpose);
else
log_fn(LOG_INFO,"Abandoning circ %d (state %d:%s, purpose %d)", victim->n_circ_id,
victim->state, circuit_state_to_string[victim->state], victim->purpose);
victim->state, circuit_state_to_string(victim->state), victim->purpose);
circuit_log_path(LOG_INFO,victim);
circuit_mark_for_close(victim);
}

View file

@ -44,6 +44,7 @@ conn_type_to_string(int type)
case CONN_TYPE_CONTROL_LISTENER: return "Control listener";
case CONN_TYPE_CONTROL: return "Control";
default:
log_fn(LOG_WARN, "Bug: unknown connection type %d", type);
tor_snprintf(buf, sizeof(buf), "unknown [%d]", type);
return buf;
}
@ -117,6 +118,7 @@ conn_state_to_string(int type, int state) {
break;
}
log_fn(LOG_WARN, "Bug: unknown connection state %d (type %d)", state, type);
tor_snprintf(buf, sizeof(buf),
"unknown state [%d] on unknown [%s] connection",
state, conn_type_to_string(type));

View file

@ -357,14 +357,16 @@ dirserv_add_descriptor(const char **desc, const char **msg)
/* Is there too much clock skew? */
now = time(NULL);
if (ri->published_on > now+ROUTER_ALLOW_SKEW) {
log_fn(LOG_NOTICE, "Publication time for nickname '%s' is too far in the future; possible clock skew. Not adding.", ri->nickname);
log_fn(LOG_NOTICE, "Publication time for nickname '%s' is too far (%d minutes) in the future; possible clock skew. Not adding.",
ri->nickname, (int)((ri->published_on-now)/60));
*msg = "Rejected: Your clock is set too far in the future, or your timezone is not correct.";
routerinfo_free(ri);
*desc = end;
return -1;
}
if (ri->published_on < now-ROUTER_MAX_AGE) {
log_fn(LOG_NOTICE, "Publication time for router with nickname '%s' is too far in the past. Not adding.", ri->nickname);
log_fn(LOG_NOTICE, "Publication time for router with nickname '%s' is too far (%d minutes) in the past. Not adding.",
ri->nickname, (int)((now-ri->published_on)/60));
*msg = "Rejected: Server is expired, or your clock is too far in the past, or your timezone is not correct.";
routerinfo_free(ri);
*desc = end;

View file

@ -1165,7 +1165,7 @@ void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
/********************************* circuitlist.c ***********************/
extern const char *circuit_state_to_string[];
const char *circuit_state_to_string(int state);
enum which_conn_changed_t { P_CONN_CHANGED=1, N_CONN_CHANGED=0 };
void circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
connection_t *conn,

View file

@ -988,7 +988,7 @@ rend_service_dump_stats(int severity)
continue;
}
log(severity, " Intro point at %s: circuit is %s",nickname,
circuit_state_to_string[circ->state]);
circuit_state_to_string(circ->state));
}
}
}