mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-01 08:03:31 +01:00
Log descriptions of nodes, not just nicknames.
This patch introduces a few new functions in router.c to produce a more helpful description of a node than its nickame, and then tweaks nearly all log messages taking a nickname as an argument to call these functions instead. There are a few cases where I left the old log messages alone: in these cases, the nickname was that of an authority (whose nicknames are useful and unique), or the message already included an identity and/or an address. I might have missed a couple more too. This is a fix for bug 3045.
This commit is contained in:
parent
ede102fd46
commit
b95dd03e5f
@ -1753,10 +1753,9 @@ circuit_handle_first_hop(origin_circuit_t *circ)
|
|||||||
|
|
||||||
if (!n_conn) {
|
if (!n_conn) {
|
||||||
/* not currently connected in a useful way. */
|
/* not currently connected in a useful way. */
|
||||||
const char *name = strlen(firsthop->extend_info->nickname) ?
|
|
||||||
firsthop->extend_info->nickname : fmt_addr(&firsthop->extend_info->addr);
|
|
||||||
log_info(LD_CIRC, "Next router is %s: %s ",
|
log_info(LD_CIRC, "Next router is %s: %s ",
|
||||||
safe_str_client(name), msg?msg:"???");
|
safe_str_client(extend_info_describe(firsthop->extend_info)),
|
||||||
|
msg?msg:"???");
|
||||||
circ->_base.n_hop = extend_info_dup(firsthop->extend_info);
|
circ->_base.n_hop = extend_info_dup(firsthop->extend_info);
|
||||||
|
|
||||||
if (should_launch) {
|
if (should_launch) {
|
||||||
@ -2039,7 +2038,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
|
|||||||
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
|
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
|
||||||
log_info(LD_CIRC,"First hop: finished sending %s cell to '%s'",
|
log_info(LD_CIRC,"First hop: finished sending %s cell to '%s'",
|
||||||
fast ? "CREATE_FAST" : "CREATE",
|
fast ? "CREATE_FAST" : "CREATE",
|
||||||
router ? router->nickname : "<unnamed>");
|
router ? router_describe(router) : "<unnamed>");
|
||||||
} else {
|
} else {
|
||||||
tor_assert(circ->cpath->state == CPATH_STATE_OPEN);
|
tor_assert(circ->cpath->state == CPATH_STATE_OPEN);
|
||||||
tor_assert(circ->_base.state == CIRCUIT_STATE_BUILDING);
|
tor_assert(circ->_base.state == CIRCUIT_STATE_BUILDING);
|
||||||
@ -2829,7 +2828,7 @@ choose_good_exit_server_general(routerlist_t *dir, int need_uptime,
|
|||||||
|
|
||||||
tor_free(n_supported);
|
tor_free(n_supported);
|
||||||
if (router) {
|
if (router) {
|
||||||
log_info(LD_CIRC, "Chose exit server '%s'", router->nickname);
|
log_info(LD_CIRC, "Chose exit server '%s'", router_describe(router));
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
if (options->ExitNodes) {
|
if (options->ExitNodes) {
|
||||||
@ -2936,7 +2935,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
|
|||||||
log_warn(LD_BUG, "Using %s '%s' which is listed in ExcludeNodes%s, "
|
log_warn(LD_BUG, "Using %s '%s' which is listed in ExcludeNodes%s, "
|
||||||
"even though StrictNodes is set. Please report. "
|
"even though StrictNodes is set. Please report. "
|
||||||
"(Circuit purpose: %s)",
|
"(Circuit purpose: %s)",
|
||||||
description, exit->nickname,
|
description, extend_info_describe(exit),
|
||||||
rs==options->ExcludeNodes?"":" or ExcludeExitNodes",
|
rs==options->ExcludeNodes?"":" or ExcludeExitNodes",
|
||||||
circuit_purpose_to_string(purpose));
|
circuit_purpose_to_string(purpose));
|
||||||
} else {
|
} else {
|
||||||
@ -2945,7 +2944,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
|
|||||||
"prevent this (and possibly break your Tor functionality), "
|
"prevent this (and possibly break your Tor functionality), "
|
||||||
"set the StrictNodes configuration option. "
|
"set the StrictNodes configuration option. "
|
||||||
"(Circuit purpose: %s)",
|
"(Circuit purpose: %s)",
|
||||||
description, exit->nickname,
|
description, extend_info_describe(exit),
|
||||||
rs==options->ExcludeNodes?"":" or ExcludeExitNodes",
|
rs==options->ExcludeNodes?"":" or ExcludeExitNodes",
|
||||||
circuit_purpose_to_string(purpose));
|
circuit_purpose_to_string(purpose));
|
||||||
}
|
}
|
||||||
@ -2976,7 +2975,8 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
|
|||||||
|
|
||||||
if (exit) { /* the circuit-builder pre-requested one */
|
if (exit) { /* the circuit-builder pre-requested one */
|
||||||
warn_if_last_router_excluded(circ, exit);
|
warn_if_last_router_excluded(circ, exit);
|
||||||
log_info(LD_CIRC,"Using requested exit node '%s'", exit->nickname);
|
log_info(LD_CIRC,"Using requested exit node '%s'",
|
||||||
|
extend_info_describe(exit));
|
||||||
exit = extend_info_dup(exit);
|
exit = extend_info_dup(exit);
|
||||||
} else { /* we have to decide one */
|
} else { /* we have to decide one */
|
||||||
routerinfo_t *router =
|
routerinfo_t *router =
|
||||||
@ -3025,8 +3025,8 @@ circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *exit)
|
|||||||
circuit_append_new_exit(circ, exit);
|
circuit_append_new_exit(circ, exit);
|
||||||
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
|
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
|
||||||
if ((err_reason = circuit_send_next_onion_skin(circ))<0) {
|
if ((err_reason = circuit_send_next_onion_skin(circ))<0) {
|
||||||
log_warn(LD_CIRC, "Couldn't extend circuit to new point '%s'.",
|
log_warn(LD_CIRC, "Couldn't extend circuit to new point %s.",
|
||||||
exit->nickname);
|
extend_info_describe(exit));
|
||||||
circuit_mark_for_close(TO_CIRCUIT(circ), -err_reason);
|
circuit_mark_for_close(TO_CIRCUIT(circ), -err_reason);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -3250,7 +3250,8 @@ onion_extend_cpath(origin_circuit_t *circ)
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_debug(LD_CIRC,"Chose router %s for hop %d (exit is %s)",
|
log_debug(LD_CIRC,"Chose router %s for hop %d (exit is %s)",
|
||||||
info->nickname, cur_len+1, build_state_get_exit_nickname(state));
|
extend_info_describe(info),
|
||||||
|
cur_len+1, build_state_get_exit_nickname(state));
|
||||||
|
|
||||||
onion_append_hop(&circ->cpath, info);
|
onion_append_hop(&circ->cpath, info);
|
||||||
extend_info_free(info);
|
extend_info_free(info);
|
||||||
@ -3526,20 +3527,24 @@ log_entry_guards(int severity)
|
|||||||
smartlist_t *elements = smartlist_create();
|
smartlist_t *elements = smartlist_create();
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e,
|
SMARTLIST_FOREACH_BEGIN(entry_guards, entry_guard_t *, e)
|
||||||
{
|
{
|
||||||
const char *msg = NULL;
|
const char *msg = NULL;
|
||||||
char *cp;
|
char *cp;
|
||||||
if (entry_is_live(e, 0, 1, 0, &msg))
|
if (entry_is_live(e, 0, 1, 0, &msg))
|
||||||
tor_asprintf(&cp, "%s (up %s)",
|
tor_asprintf(&cp, "%s [%s] (up %s)",
|
||||||
e->nickname,
|
e->nickname,
|
||||||
|
hex_str(e->identity, DIGEST_LEN),
|
||||||
e->made_contact ? "made-contact" : "never-contacted");
|
e->made_contact ? "made-contact" : "never-contacted");
|
||||||
else
|
else
|
||||||
tor_asprintf(&cp, "%s (%s, %s)",
|
tor_asprintf(&cp, "%s [%s] (%s, %s)",
|
||||||
e->nickname, msg,
|
e->nickname,
|
||||||
|
hex_str(e->identity, DIGEST_LEN),
|
||||||
|
msg,
|
||||||
e->made_contact ? "made-contact" : "never-contacted");
|
e->made_contact ? "made-contact" : "never-contacted");
|
||||||
smartlist_add(elements, cp);
|
smartlist_add(elements, cp);
|
||||||
});
|
}
|
||||||
|
SMARTLIST_FOREACH_END(e);
|
||||||
|
|
||||||
s = smartlist_join_strings(elements, ",", 0, NULL);
|
s = smartlist_join_strings(elements, ",", 0, NULL);
|
||||||
SMARTLIST_FOREACH(elements, char*, cp, tor_free(cp));
|
SMARTLIST_FOREACH(elements, char*, cp, tor_free(cp));
|
||||||
@ -3607,7 +3612,8 @@ add_an_entry_guard(routerinfo_t *chosen, int reset_status)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
entry = tor_malloc_zero(sizeof(entry_guard_t));
|
entry = tor_malloc_zero(sizeof(entry_guard_t));
|
||||||
log_info(LD_CIRC, "Chose '%s' as new entry guard.", router->nickname);
|
log_info(LD_CIRC, "Chose '%s' as new entry guard.",
|
||||||
|
router_describe(router));
|
||||||
strlcpy(entry->nickname, router->nickname, sizeof(entry->nickname));
|
strlcpy(entry->nickname, router->nickname, sizeof(entry->nickname));
|
||||||
memcpy(entry->identity, router->cache_info.identity_digest, DIGEST_LEN);
|
memcpy(entry->identity, router->cache_info.identity_digest, DIGEST_LEN);
|
||||||
/* Choose expiry time smudged over the past month. The goal here
|
/* Choose expiry time smudged over the past month. The goal here
|
||||||
@ -3800,8 +3806,9 @@ entry_guards_compute_status(or_options_t *options, time_t now)
|
|||||||
const char *reason = digestmap_get(reasons, entry->identity);
|
const char *reason = digestmap_get(reasons, entry->identity);
|
||||||
const char *live_msg = "";
|
const char *live_msg = "";
|
||||||
routerinfo_t *r = entry_is_live(entry, 0, 1, 0, &live_msg);
|
routerinfo_t *r = entry_is_live(entry, 0, 1, 0, &live_msg);
|
||||||
log_info(LD_CIRC, "Summary: Entry '%s' is %s, %s%s%s, and %s%s.",
|
log_info(LD_CIRC, "Summary: Entry %s [%s] is %s, %s%s%s, and %s%s.",
|
||||||
entry->nickname,
|
entry->nickname,
|
||||||
|
hex_str(entry->identity, DIGEST_LEN),
|
||||||
entry->unreachable_since ? "unreachable" : "reachable",
|
entry->unreachable_since ? "unreachable" : "reachable",
|
||||||
entry->bad_since ? "unusable" : "usable",
|
entry->bad_since ? "unusable" : "usable",
|
||||||
reason ? ", ": "",
|
reason ? ", ": "",
|
||||||
|
@ -274,8 +274,10 @@ circuit_count_pending_on_or_conn(or_connection_t *or_conn)
|
|||||||
circuit_get_all_pending_on_or_conn(sl, or_conn);
|
circuit_get_all_pending_on_or_conn(sl, or_conn);
|
||||||
cnt = smartlist_len(sl);
|
cnt = smartlist_len(sl);
|
||||||
smartlist_free(sl);
|
smartlist_free(sl);
|
||||||
log_debug(LD_CIRC,"or_conn to %s, %d pending circs",
|
log_debug(LD_CIRC,"or_conn to %s at %s, %d pending circs",
|
||||||
or_conn->nickname ? or_conn->nickname : "NULL", cnt);
|
or_conn->nickname ? or_conn->nickname : "NULL",
|
||||||
|
or_conn->_base.address,
|
||||||
|
cnt);
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,8 +1335,8 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
|
|||||||
conn->_base.state = AP_CONN_STATE_RENDDESC_WAIT;
|
conn->_base.state = AP_CONN_STATE_RENDDESC_WAIT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
log_info(LD_REND,"Chose '%s' as intro point for '%s'.",
|
log_info(LD_REND,"Chose %s as intro point for '%s'.",
|
||||||
extend_info->nickname,
|
extend_info_describe(extend_info),
|
||||||
safe_str_client(conn->rend_data->onion_address));
|
safe_str_client(conn->rend_data->onion_address));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,8 +274,8 @@ command_process_create_cell(cell_t *cell, or_connection_t *conn)
|
|||||||
cell->circ_id, (int)(time(NULL) - conn->_base.timestamp_created));
|
cell->circ_id, (int)(time(NULL) - conn->_base.timestamp_created));
|
||||||
if (router)
|
if (router)
|
||||||
log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
|
log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
|
||||||
"Details: nickname \"%s\", platform %s.",
|
"Details: router %s, platform %s.",
|
||||||
router->nickname, escaped(router->platform));
|
router_describe(router), escaped(router->platform));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,12 +503,12 @@ connection_ap_expire_beginning(void)
|
|||||||
}
|
}
|
||||||
tor_assert(circ->purpose == CIRCUIT_PURPOSE_C_GENERAL);
|
tor_assert(circ->purpose == CIRCUIT_PURPOSE_C_GENERAL);
|
||||||
log_fn(cutoff < 15 ? LOG_INFO : severity, LD_APP,
|
log_fn(cutoff < 15 ? LOG_INFO : severity, LD_APP,
|
||||||
"We tried for %d seconds to connect to '%s' using exit '%s'."
|
"We tried for %d seconds to connect to '%s' using exit %s."
|
||||||
" Retrying on a new circuit.",
|
" Retrying on a new circuit.",
|
||||||
seconds_idle,
|
seconds_idle,
|
||||||
safe_str_client(conn->socks_request->address),
|
safe_str_client(conn->socks_request->address),
|
||||||
conn->cpath_layer ?
|
conn->cpath_layer ?
|
||||||
conn->cpath_layer->extend_info->nickname : "*unnamed*");
|
extend_info_describe(conn->cpath_layer->extend_info): "*unnamed*");
|
||||||
/* send an end down the circuit */
|
/* send an end down the circuit */
|
||||||
connection_edge_end(conn, END_STREAM_REASON_TIMEOUT);
|
connection_edge_end(conn, END_STREAM_REASON_TIMEOUT);
|
||||||
/* un-mark it as ending, since we're going to reuse it */
|
/* un-mark it as ending, since we're going to reuse it */
|
||||||
@ -1830,7 +1830,8 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
|
|||||||
if (r) {
|
if (r) {
|
||||||
log_info(LD_APP,
|
log_info(LD_APP,
|
||||||
"Redirecting address %s to exit at enclave router %s",
|
"Redirecting address %s to exit at enclave router %s",
|
||||||
safe_str_client(socks->address), r->nickname);
|
safe_str_client(socks->address),
|
||||||
|
router_describe(r));
|
||||||
/* use the hex digest, not nickname, in case there are two
|
/* use the hex digest, not nickname, in case there are two
|
||||||
routers with this nickname */
|
routers with this nickname */
|
||||||
conn->chosen_exit_name =
|
conn->chosen_exit_name =
|
||||||
|
@ -525,8 +525,9 @@ directory_initiate_command_routerstatus_rend(routerstatus_t *status,
|
|||||||
router = router_get_by_digest(status->identity_digest);
|
router = router_get_by_digest(status->identity_digest);
|
||||||
|
|
||||||
if (!router && anonymized_connection) {
|
if (!router && anonymized_connection) {
|
||||||
log_info(LD_DIR, "Not sending anonymized request to directory '%s'; we "
|
log_info(LD_DIR, "Not sending anonymized request to directory %s; we "
|
||||||
"don't have its router descriptor.", status->nickname);
|
"don't have its router descriptor.",
|
||||||
|
routerstatus_describe(status));
|
||||||
return;
|
return;
|
||||||
} else if (router) {
|
} else if (router) {
|
||||||
address = router->address;
|
address = router->address;
|
||||||
@ -539,10 +540,10 @@ directory_initiate_command_routerstatus_rend(routerstatus_t *status,
|
|||||||
|
|
||||||
if (options->ExcludeNodes && options->StrictNodes &&
|
if (options->ExcludeNodes && options->StrictNodes &&
|
||||||
routerset_contains_routerstatus(options->ExcludeNodes, status)) {
|
routerset_contains_routerstatus(options->ExcludeNodes, status)) {
|
||||||
log_warn(LD_DIR, "Wanted to contact directory mirror '%s' for %s, but "
|
log_warn(LD_DIR, "Wanted to contact directory mirror %s for %s, but "
|
||||||
"it's in our ExcludedNodes list and StrictNodes is set. "
|
"it's in our ExcludedNodes list and StrictNodes is set. "
|
||||||
"Skipping. This choice might make your Tor not work.",
|
"Skipping. This choice might make your Tor not work.",
|
||||||
status->nickname,
|
routerstatus_describe(status),
|
||||||
dir_conn_purpose_to_string(dir_purpose));
|
dir_conn_purpose_to_string(dir_purpose));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -518,14 +518,15 @@ dirserv_router_has_valid_address(routerinfo_t *ri)
|
|||||||
if (get_options()->DirAllowPrivateAddresses)
|
if (get_options()->DirAllowPrivateAddresses)
|
||||||
return 0; /* whatever it is, we're fine with it */
|
return 0; /* whatever it is, we're fine with it */
|
||||||
if (!tor_inet_aton(ri->address, &iaddr)) {
|
if (!tor_inet_aton(ri->address, &iaddr)) {
|
||||||
log_info(LD_DIRSERV,"Router '%s' published non-IP address '%s'. Refusing.",
|
log_info(LD_DIRSERV,"Router %s published non-IP address '%s'. Refusing.",
|
||||||
ri->nickname, ri->address);
|
router_describe(ri),
|
||||||
|
ri->address);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (is_internal_IP(ntohl(iaddr.s_addr), 0)) {
|
if (is_internal_IP(ntohl(iaddr.s_addr), 0)) {
|
||||||
log_info(LD_DIRSERV,
|
log_info(LD_DIRSERV,
|
||||||
"Router '%s' published internal IP address '%s'. Refusing.",
|
"Router %s published internal IP address '%s'. Refusing.",
|
||||||
ri->nickname, ri->address);
|
router_describe(ri), ri->address);
|
||||||
return -1; /* it's a private IP, we should reject it */
|
return -1; /* it's a private IP, we should reject it */
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -554,10 +555,11 @@ authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
|
|||||||
/* Is there too much clock skew? */
|
/* Is there too much clock skew? */
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
if (ri->cache_info.published_on > now+ROUTER_ALLOW_SKEW) {
|
if (ri->cache_info.published_on > now+ROUTER_ALLOW_SKEW) {
|
||||||
log_fn(severity, LD_DIRSERV, "Publication time for nickname '%s' is too "
|
log_fn(severity, LD_DIRSERV, "Publication time for %s is too "
|
||||||
"far (%d minutes) in the future; possible clock skew. Not adding "
|
"far (%d minutes) in the future; possible clock skew. Not adding "
|
||||||
"(%s)",
|
"(%s)",
|
||||||
ri->nickname, (int)((ri->cache_info.published_on-now)/60),
|
router_describe(ri),
|
||||||
|
(int)((ri->cache_info.published_on-now)/60),
|
||||||
esc_router_info(ri));
|
esc_router_info(ri));
|
||||||
*msg = "Rejected: Your clock is set too far in the future, or your "
|
*msg = "Rejected: Your clock is set too far in the future, or your "
|
||||||
"timezone is not correct.";
|
"timezone is not correct.";
|
||||||
@ -565,9 +567,10 @@ authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
|
|||||||
}
|
}
|
||||||
if (ri->cache_info.published_on < now-ROUTER_MAX_AGE_TO_PUBLISH) {
|
if (ri->cache_info.published_on < now-ROUTER_MAX_AGE_TO_PUBLISH) {
|
||||||
log_fn(severity, LD_DIRSERV,
|
log_fn(severity, LD_DIRSERV,
|
||||||
"Publication time for router with nickname '%s' is too far "
|
"Publication time for %s is too far "
|
||||||
"(%d minutes) in the past. Not adding (%s)",
|
"(%d minutes) in the past. Not adding (%s)",
|
||||||
ri->nickname, (int)((now-ri->cache_info.published_on)/60),
|
router_describe(ri),
|
||||||
|
(int)((now-ri->cache_info.published_on)/60),
|
||||||
esc_router_info(ri));
|
esc_router_info(ri));
|
||||||
*msg = "Rejected: Server is expired, or your clock is too far in the past,"
|
*msg = "Rejected: Server is expired, or your clock is too far in the past,"
|
||||||
" or your timezone is not correct.";
|
" or your timezone is not correct.";
|
||||||
@ -575,9 +578,10 @@ authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
|
|||||||
}
|
}
|
||||||
if (dirserv_router_has_valid_address(ri) < 0) {
|
if (dirserv_router_has_valid_address(ri) < 0) {
|
||||||
log_fn(severity, LD_DIRSERV,
|
log_fn(severity, LD_DIRSERV,
|
||||||
"Router with nickname '%s' has invalid address '%s'. "
|
"Router %s has invalid address '%s'. "
|
||||||
"Not adding (%s).",
|
"Not adding (%s).",
|
||||||
ri->nickname, ri->address,
|
router_describe(ri),
|
||||||
|
ri->address,
|
||||||
esc_router_info(ri));
|
esc_router_info(ri));
|
||||||
*msg = "Rejected: Address is not an IP, or IP is a private address.";
|
*msg = "Rejected: Address is not an IP, or IP is a private address.";
|
||||||
return -1;
|
return -1;
|
||||||
@ -720,9 +724,9 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)
|
|||||||
&& router_differences_are_cosmetic(ri_old, ri)
|
&& router_differences_are_cosmetic(ri_old, ri)
|
||||||
&& !router_is_me(ri)) {
|
&& !router_is_me(ri)) {
|
||||||
log_info(LD_DIRSERV,
|
log_info(LD_DIRSERV,
|
||||||
"Not replacing descriptor from '%s' (source: %s); "
|
"Not replacing descriptor from %s (source: %s); "
|
||||||
"differences are cosmetic.",
|
"differences are cosmetic.",
|
||||||
ri->nickname, source);
|
router_describe(ri), source);
|
||||||
*msg = "Not replacing router descriptor; no information has changed since "
|
*msg = "Not replacing router descriptor; no information has changed since "
|
||||||
"the last one with this identity.";
|
"the last one with this identity.";
|
||||||
control_event_or_authdir_new_descriptor("DROPPED",
|
control_event_or_authdir_new_descriptor("DROPPED",
|
||||||
@ -824,10 +828,12 @@ directory_remove_invalid(void)
|
|||||||
for (i = 0; i < smartlist_len(rl->routers); ++i) {
|
for (i = 0; i < smartlist_len(rl->routers); ++i) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
routerinfo_t *ent = smartlist_get(rl->routers, i);
|
routerinfo_t *ent = smartlist_get(rl->routers, i);
|
||||||
|
char description[NODE_DESC_BUF_LEN];
|
||||||
uint32_t r = dirserv_router_get_status(ent, &msg);
|
uint32_t r = dirserv_router_get_status(ent, &msg);
|
||||||
|
router_get_description(description, ent);
|
||||||
if (r & FP_REJECT) {
|
if (r & FP_REJECT) {
|
||||||
log_info(LD_DIRSERV, "Router '%s' is now rejected: %s",
|
log_info(LD_DIRSERV, "Router %s is now rejected: %s",
|
||||||
ent->nickname, msg?msg:"");
|
description, msg?msg:"");
|
||||||
routerlist_remove(rl, ent, 0, time(NULL));
|
routerlist_remove(rl, ent, 0, time(NULL));
|
||||||
i--;
|
i--;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
@ -835,25 +841,25 @@ directory_remove_invalid(void)
|
|||||||
}
|
}
|
||||||
if (bool_neq((r & FP_NAMED), ent->is_named)) {
|
if (bool_neq((r & FP_NAMED), ent->is_named)) {
|
||||||
log_info(LD_DIRSERV,
|
log_info(LD_DIRSERV,
|
||||||
"Router '%s' is now %snamed.", ent->nickname,
|
"Router %s is now %snamed.", description,
|
||||||
(r&FP_NAMED)?"":"un");
|
(r&FP_NAMED)?"":"un");
|
||||||
ent->is_named = (r&FP_NAMED)?1:0;
|
ent->is_named = (r&FP_NAMED)?1:0;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
if (bool_neq((r & FP_INVALID), !ent->is_valid)) {
|
if (bool_neq((r & FP_INVALID), !ent->is_valid)) {
|
||||||
log_info(LD_DIRSERV, "Router '%s' is now %svalid.", ent->nickname,
|
log_info(LD_DIRSERV, "Router '%s' is now %svalid.", description,
|
||||||
(r&FP_INVALID) ? "in" : "");
|
(r&FP_INVALID) ? "in" : "");
|
||||||
ent->is_valid = (r&FP_INVALID)?0:1;
|
ent->is_valid = (r&FP_INVALID)?0:1;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
if (bool_neq((r & FP_BADDIR), ent->is_bad_directory)) {
|
if (bool_neq((r & FP_BADDIR), ent->is_bad_directory)) {
|
||||||
log_info(LD_DIRSERV, "Router '%s' is now a %s directory", ent->nickname,
|
log_info(LD_DIRSERV, "Router '%s' is now a %s directory", description,
|
||||||
(r & FP_BADDIR) ? "bad" : "good");
|
(r & FP_BADDIR) ? "bad" : "good");
|
||||||
ent->is_bad_directory = (r&FP_BADDIR) ? 1: 0;
|
ent->is_bad_directory = (r&FP_BADDIR) ? 1: 0;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
if (bool_neq((r & FP_BADEXIT), ent->is_bad_exit)) {
|
if (bool_neq((r & FP_BADEXIT), ent->is_bad_exit)) {
|
||||||
log_info(LD_DIRSERV, "Router '%s' is now a %s exit", ent->nickname,
|
log_info(LD_DIRSERV, "Router '%s' is now a %s exit", description,
|
||||||
(r & FP_BADEXIT) ? "bad" : "good");
|
(r & FP_BADEXIT) ? "bad" : "good");
|
||||||
ent->is_bad_exit = (r&FP_BADEXIT) ? 1: 0;
|
ent->is_bad_exit = (r&FP_BADEXIT) ? 1: 0;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
@ -3163,7 +3169,8 @@ dirserv_orconn_tls_done(const char *address,
|
|||||||
if (!bridge_auth || ri->purpose == ROUTER_PURPOSE_BRIDGE) {
|
if (!bridge_auth || ri->purpose == ROUTER_PURPOSE_BRIDGE) {
|
||||||
tor_addr_t addr, *addrp=NULL;
|
tor_addr_t addr, *addrp=NULL;
|
||||||
log_info(LD_DIRSERV, "Found router %s to be reachable at %s:%d. Yay.",
|
log_info(LD_DIRSERV, "Found router %s to be reachable at %s:%d. Yay.",
|
||||||
ri->nickname, address, ri->or_port );
|
router_describe(ri),
|
||||||
|
address, ri->or_port);
|
||||||
if (tor_addr_from_str(&addr, ri->address) != -1)
|
if (tor_addr_from_str(&addr, ri->address) != -1)
|
||||||
addrp = &addr;
|
addrp = &addr;
|
||||||
else
|
else
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "reasons.h"
|
#include "reasons.h"
|
||||||
#include "relay.h"
|
#include "relay.h"
|
||||||
#include "rendcommon.h"
|
#include "rendcommon.h"
|
||||||
|
#include "router.h"
|
||||||
#include "routerlist.h"
|
#include "routerlist.h"
|
||||||
#include "routerparse.h"
|
#include "routerparse.h"
|
||||||
|
|
||||||
@ -749,9 +750,9 @@ connection_ap_process_end_not_open(
|
|||||||
(tor_inet_aton(conn->socks_request->address, &in) &&
|
(tor_inet_aton(conn->socks_request->address, &in) &&
|
||||||
!conn->chosen_exit_name))) {
|
!conn->chosen_exit_name))) {
|
||||||
log_info(LD_APP,
|
log_info(LD_APP,
|
||||||
"Exitrouter '%s' seems to be more restrictive than its exit "
|
"Exitrouter %s seems to be more restrictive than its exit "
|
||||||
"policy. Not using this router as exit for now.",
|
"policy. Not using this router as exit for now.",
|
||||||
exitrouter->nickname);
|
router_describe(exitrouter));
|
||||||
policies_set_router_exitpolicy_to_reject_all(exitrouter);
|
policies_set_router_exitpolicy_to_reject_all(exitrouter);
|
||||||
}
|
}
|
||||||
/* rewrite it to an IP if we learned one. */
|
/* rewrite it to an IP if we learned one. */
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "rendclient.h"
|
#include "rendclient.h"
|
||||||
#include "rendcommon.h"
|
#include "rendcommon.h"
|
||||||
#include "rephist.h"
|
#include "rephist.h"
|
||||||
|
#include "router.h"
|
||||||
#include "routerlist.h"
|
#include "routerlist.h"
|
||||||
|
|
||||||
static extend_info_t *rend_client_get_random_intro_impl(
|
static extend_info_t *rend_client_get_random_intro_impl(
|
||||||
@ -90,12 +91,13 @@ rend_client_reextend_intro_circuit(origin_circuit_t *circ)
|
|||||||
if (circ->remaining_relay_early_cells) {
|
if (circ->remaining_relay_early_cells) {
|
||||||
log_info(LD_REND,
|
log_info(LD_REND,
|
||||||
"Re-extending circ %d, this time to %s.",
|
"Re-extending circ %d, this time to %s.",
|
||||||
circ->_base.n_circ_id, extend_info->nickname);
|
circ->_base.n_circ_id,
|
||||||
|
safe_str_client(extend_info_describe(extend_info)));
|
||||||
result = circuit_extend_to_new_exit(circ, extend_info);
|
result = circuit_extend_to_new_exit(circ, extend_info);
|
||||||
} else {
|
} else {
|
||||||
log_info(LD_REND,
|
log_info(LD_REND,
|
||||||
"Building a new introduction circuit, this time to %s.",
|
"Building a new introduction circuit, this time to %s.",
|
||||||
extend_info->nickname);
|
safe_str_client(extend_info_describe(extend_info)));
|
||||||
circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_FINISHED);
|
circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_FINISHED);
|
||||||
if (!circuit_launch_by_extend_info(CIRCUIT_PURPOSE_C_INTRODUCING,
|
if (!circuit_launch_by_extend_info(CIRCUIT_PURPOSE_C_INTRODUCING,
|
||||||
extend_info,
|
extend_info,
|
||||||
@ -168,7 +170,8 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
|
|||||||
"have a v2 rend desc with %d intro points. "
|
"have a v2 rend desc with %d intro points. "
|
||||||
"Trying a different intro point...",
|
"Trying a different intro point...",
|
||||||
safe_str_client(introcirc->rend_data->onion_address),
|
safe_str_client(introcirc->rend_data->onion_address),
|
||||||
introcirc->build_state->chosen_exit->nickname,
|
safe_str_client(extend_info_describe(
|
||||||
|
introcirc->build_state->chosen_exit)),
|
||||||
smartlist_len(entry->parsed->intro_nodes));
|
smartlist_len(entry->parsed->intro_nodes));
|
||||||
|
|
||||||
if (rend_client_reextend_intro_circuit(introcirc)) {
|
if (rend_client_reextend_intro_circuit(introcirc)) {
|
||||||
@ -343,8 +346,8 @@ rend_client_introduction_acked(origin_circuit_t *circ,
|
|||||||
* If none remain, refetch the service descriptor.
|
* If none remain, refetch the service descriptor.
|
||||||
*/
|
*/
|
||||||
log_info(LD_REND, "Got nack for %s from %s...",
|
log_info(LD_REND, "Got nack for %s from %s...",
|
||||||
safe_str_client(circ->rend_data->onion_address),
|
safe_str_client(circ->rend_data->onion_address),
|
||||||
circ->build_state->chosen_exit->nickname);
|
safe_str_client(extend_info_describe(circ->build_state->chosen_exit)));
|
||||||
if (rend_client_remove_intro_point(circ->build_state->chosen_exit,
|
if (rend_client_remove_intro_point(circ->build_state->chosen_exit,
|
||||||
circ->rend_data) > 0) {
|
circ->rend_data) > 0) {
|
||||||
/* There are introduction points left. Re-extend the circuit to
|
/* There are introduction points left. Re-extend the circuit to
|
||||||
@ -497,12 +500,12 @@ directory_get_from_hs_dir(const char *desc_id, const rend_data_t *rend_query)
|
|||||||
log_info(LD_REND, "Sending fetch request for v2 descriptor for "
|
log_info(LD_REND, "Sending fetch request for v2 descriptor for "
|
||||||
"service '%s' with descriptor ID '%s', auth type %d, "
|
"service '%s' with descriptor ID '%s', auth type %d, "
|
||||||
"and descriptor cookie '%s' to hidden service "
|
"and descriptor cookie '%s' to hidden service "
|
||||||
"directory '%s' on port %d.",
|
"directory %s",
|
||||||
rend_query->onion_address, desc_id_base32,
|
rend_query->onion_address, desc_id_base32,
|
||||||
rend_query->auth_type,
|
rend_query->auth_type,
|
||||||
(rend_query->auth_type == REND_NO_AUTH ? "[none]" :
|
(rend_query->auth_type == REND_NO_AUTH ? "[none]" :
|
||||||
escaped_safe_str_client(descriptor_cookie_base64)),
|
escaped_safe_str_client(descriptor_cookie_base64)),
|
||||||
hs_dir->nickname, hs_dir->dir_port);
|
routerstatus_describe(hs_dir));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +474,8 @@ rend_config_services(or_options_t *options, int validate_only)
|
|||||||
if (keep_it)
|
if (keep_it)
|
||||||
continue;
|
continue;
|
||||||
log_info(LD_REND, "Closing intro point %s for service %s.",
|
log_info(LD_REND, "Closing intro point %s for service %s.",
|
||||||
safe_str_client(oc->build_state->chosen_exit->nickname),
|
safe_str_client(extend_info_describe(
|
||||||
|
oc->build_state->chosen_exit)),
|
||||||
oc->rend_data->onion_address);
|
oc->rend_data->onion_address);
|
||||||
circuit_mark_for_close(circ, END_CIRC_REASON_FINISHED);
|
circuit_mark_for_close(circ, END_CIRC_REASON_FINISHED);
|
||||||
/* XXXX Is there another reason we should use here? */
|
/* XXXX Is there another reason we should use here? */
|
||||||
@ -1146,7 +1147,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
|
|||||||
if (!launched) { /* give up */
|
if (!launched) { /* give up */
|
||||||
log_warn(LD_REND, "Giving up launching first hop of circuit to rendezvous "
|
log_warn(LD_REND, "Giving up launching first hop of circuit to rendezvous "
|
||||||
"point %s for service %s.",
|
"point %s for service %s.",
|
||||||
escaped_safe_str_client(extend_info->nickname),
|
safe_str_client(extend_info_describe(extend_info)),
|
||||||
serviceid);
|
serviceid);
|
||||||
reason = END_CIRC_REASON_CONNECTFAILED;
|
reason = END_CIRC_REASON_CONNECTFAILED;
|
||||||
goto err;
|
goto err;
|
||||||
@ -1154,7 +1155,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
|
|||||||
log_info(LD_REND,
|
log_info(LD_REND,
|
||||||
"Accepted intro; launching circuit to %s "
|
"Accepted intro; launching circuit to %s "
|
||||||
"(cookie %s) for service %s.",
|
"(cookie %s) for service %s.",
|
||||||
escaped_safe_str_client(extend_info->nickname),
|
safe_str_client(extend_info_describe(extend_info)),
|
||||||
hexcookie, serviceid);
|
hexcookie, serviceid);
|
||||||
tor_assert(launched->build_state);
|
tor_assert(launched->build_state);
|
||||||
/* Fill in the circuit's state. */
|
/* Fill in the circuit's state. */
|
||||||
@ -1206,7 +1207,8 @@ rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc)
|
|||||||
"Attempt to build circuit to %s for rendezvous has failed "
|
"Attempt to build circuit to %s for rendezvous has failed "
|
||||||
"too many times or expired; giving up.",
|
"too many times or expired; giving up.",
|
||||||
oldcirc->build_state ?
|
oldcirc->build_state ?
|
||||||
oldcirc->build_state->chosen_exit->nickname : "*unknown*");
|
safe_str(extend_info_describe(oldcirc->build_state->chosen_exit))
|
||||||
|
: "*unknown*");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1220,7 +1222,7 @@ rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_info(LD_REND,"Reattempting rendezvous circuit to '%s'",
|
log_info(LD_REND,"Reattempting rendezvous circuit to '%s'",
|
||||||
oldstate->chosen_exit->nickname);
|
safe_str(extend_info_describe(oldstate->chosen_exit)));
|
||||||
|
|
||||||
newcirc = circuit_launch_by_extend_info(CIRCUIT_PURPOSE_S_CONNECT_REND,
|
newcirc = circuit_launch_by_extend_info(CIRCUIT_PURPOSE_S_CONNECT_REND,
|
||||||
oldstate->chosen_exit,
|
oldstate->chosen_exit,
|
||||||
@ -1228,7 +1230,7 @@ rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc)
|
|||||||
|
|
||||||
if (!newcirc) {
|
if (!newcirc) {
|
||||||
log_warn(LD_REND,"Couldn't relaunch rendezvous circuit to '%s'.",
|
log_warn(LD_REND,"Couldn't relaunch rendezvous circuit to '%s'.",
|
||||||
oldstate->chosen_exit->nickname);
|
safe_str(extend_info_describe(oldstate->chosen_exit)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newstate = newcirc->build_state;
|
newstate = newcirc->build_state;
|
||||||
@ -1252,7 +1254,7 @@ rend_service_launch_establish_intro(rend_service_t *service,
|
|||||||
|
|
||||||
log_info(LD_REND,
|
log_info(LD_REND,
|
||||||
"Launching circuit to introduction point %s for service %s",
|
"Launching circuit to introduction point %s for service %s",
|
||||||
escaped_safe_str_client(intro->extend_info->nickname),
|
safe_str_client(extend_info_describe(intro->extend_info)),
|
||||||
service->service_id);
|
service->service_id);
|
||||||
|
|
||||||
rep_hist_note_used_internal(time(NULL), 1, 0);
|
rep_hist_note_used_internal(time(NULL), 1, 0);
|
||||||
@ -1265,7 +1267,7 @@ rend_service_launch_establish_intro(rend_service_t *service,
|
|||||||
if (!launched) {
|
if (!launched) {
|
||||||
log_info(LD_REND,
|
log_info(LD_REND,
|
||||||
"Can't launch circuit to establish introduction at %s.",
|
"Can't launch circuit to establish introduction at %s.",
|
||||||
escaped_safe_str_client(intro->extend_info->nickname));
|
safe_str_client(extend_info_describe(intro->extend_info)));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1608,9 +1610,9 @@ directory_post_to_hs_dir(rend_service_descriptor_t *renddesc,
|
|||||||
continue;
|
continue;
|
||||||
if (!router_get_by_digest(hs_dir->identity_digest)) {
|
if (!router_get_by_digest(hs_dir->identity_digest)) {
|
||||||
log_info(LD_REND, "Not sending publish request for v2 descriptor to "
|
log_info(LD_REND, "Not sending publish request for v2 descriptor to "
|
||||||
"hidden service directory '%s'; we don't have its "
|
"hidden service directory %s; we don't have its "
|
||||||
"router descriptor. Queuing for later upload.",
|
"router descriptor. Queuing for later upload.",
|
||||||
hs_dir->nickname);
|
safe_str_client(routerstatus_describe(hs_dir)));
|
||||||
failed_upload = -1;
|
failed_upload = -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1818,7 +1820,8 @@ rend_services_introduce(void)
|
|||||||
router = router_get_by_digest(intro->extend_info->identity_digest);
|
router = router_get_by_digest(intro->extend_info->identity_digest);
|
||||||
if (!router || !find_intro_circuit(intro, service->pk_digest)) {
|
if (!router || !find_intro_circuit(intro, service->pk_digest)) {
|
||||||
log_info(LD_REND,"Giving up on %s as intro point for %s.",
|
log_info(LD_REND,"Giving up on %s as intro point for %s.",
|
||||||
intro->extend_info->nickname, service->service_id);
|
safe_str_client(extend_info_describe(intro->extend_info)),
|
||||||
|
safe_str_client(service->service_id));
|
||||||
if (service->desc) {
|
if (service->desc) {
|
||||||
SMARTLIST_FOREACH(service->desc->intro_nodes, rend_intro_point_t *,
|
SMARTLIST_FOREACH(service->desc->intro_nodes, rend_intro_point_t *,
|
||||||
dintro, {
|
dintro, {
|
||||||
@ -1884,7 +1887,8 @@ rend_services_introduce(void)
|
|||||||
tor_assert(!crypto_pk_generate_key(intro->intro_key));
|
tor_assert(!crypto_pk_generate_key(intro->intro_key));
|
||||||
smartlist_add(service->intro_nodes, intro);
|
smartlist_add(service->intro_nodes, intro);
|
||||||
log_info(LD_REND, "Picked router %s as an intro point for %s.",
|
log_info(LD_REND, "Picked router %s as an intro point for %s.",
|
||||||
router->nickname, service->service_id);
|
safe_str_client(router_describe(router)),
|
||||||
|
safe_str_client(service->service_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there's no need to launch new circuits, stop here. */
|
/* If there's no need to launch new circuits, stop here. */
|
||||||
@ -1897,7 +1901,8 @@ rend_services_introduce(void)
|
|||||||
r = rend_service_launch_establish_intro(service, intro);
|
r = rend_service_launch_establish_intro(service, intro);
|
||||||
if (r<0) {
|
if (r<0) {
|
||||||
log_warn(LD_REND, "Error launching circuit to node %s for service %s.",
|
log_warn(LD_REND, "Error launching circuit to node %s for service %s.",
|
||||||
intro->extend_info->nickname, service->service_id);
|
safe_str_client(extend_info_describe(intro->extend_info)),
|
||||||
|
safe_str_client(service->service_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,6 +634,7 @@ rep_hist_dump_stats(time_t now, int severity)
|
|||||||
digestmap_iter_t *orhist_it;
|
digestmap_iter_t *orhist_it;
|
||||||
const char *name1, *name2, *digest1, *digest2;
|
const char *name1, *name2, *digest1, *digest2;
|
||||||
char hexdigest1[HEX_DIGEST_LEN+1];
|
char hexdigest1[HEX_DIGEST_LEN+1];
|
||||||
|
char hexdigest2[HEX_DIGEST_LEN+1];
|
||||||
or_history_t *or_history;
|
or_history_t *or_history;
|
||||||
link_history_t *link_history;
|
link_history_t *link_history;
|
||||||
void *or_history_p, *link_history_p;
|
void *or_history_p, *link_history_p;
|
||||||
@ -694,7 +695,10 @@ rep_hist_dump_stats(time_t now, int severity)
|
|||||||
|
|
||||||
link_history = (link_history_t*) link_history_p;
|
link_history = (link_history_t*) link_history_p;
|
||||||
|
|
||||||
ret = tor_snprintf(buffer+len, 2048-len, "%s(%ld/%ld); ", name2,
|
base16_encode(hexdigest2, sizeof(hexdigest2), digest2, DIGEST_LEN);
|
||||||
|
ret = tor_snprintf(buffer+len, 2048-len, "%s [%s](%ld/%ld); ",
|
||||||
|
name2,
|
||||||
|
hexdigest2,
|
||||||
link_history->n_extend_ok,
|
link_history->n_extend_ok,
|
||||||
link_history->n_extend_ok+link_history->n_extend_fail);
|
link_history->n_extend_ok+link_history->n_extend_fail);
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
|
127
src/or/router.c
127
src/or/router.c
@ -2217,6 +2217,133 @@ is_legal_hexdigest(const char *s)
|
|||||||
strspn(s,HEX_CHARACTERS)==HEX_DIGEST_LEN);
|
strspn(s,HEX_CHARACTERS)==HEX_DIGEST_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Use <b>buf</b> (which must be at least NODE_DESC_BUF_LEN bytes long) to
|
||||||
|
* hold a human-readable description of a node with identity digest
|
||||||
|
* <b>id_digest</b>, named-status <b>is_named</b>, nickname <b>nickname</b>,
|
||||||
|
* and address <b>addr</b> or <b>addr32h</b>.
|
||||||
|
*
|
||||||
|
* The <b>nickname</b> and <b>addr</b> fields are optional and may be set to
|
||||||
|
* NULL. The <b>addr32h</b> field is optional and may be set to
|
||||||
|
* <b>addr32h</b>.
|
||||||
|
*
|
||||||
|
* Return a pointer to the front of <b>buf</b>.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
format_node_description(char *buf,
|
||||||
|
const char *id_digest,
|
||||||
|
int is_named,
|
||||||
|
const char *nickname,
|
||||||
|
const tor_addr_t *addr,
|
||||||
|
uint32_t addr32h)
|
||||||
|
{
|
||||||
|
char *cp;
|
||||||
|
buf[0] = '$';
|
||||||
|
base16_encode(buf+1, HEX_DIGEST_LEN+1, id_digest, DIGEST_LEN);
|
||||||
|
cp = buf+1+HEX_DIGEST_LEN;
|
||||||
|
if (nickname) {
|
||||||
|
buf[1+HEX_DIGEST_LEN] = is_named ? '=' : '~';
|
||||||
|
strlcpy(buf+1+HEX_DIGEST_LEN+1, nickname, MAX_NICKNAME_LEN+1);
|
||||||
|
cp += strlen(cp);
|
||||||
|
}
|
||||||
|
if (addr32h || addr) {
|
||||||
|
memcpy(cp, " at ", 4);
|
||||||
|
cp += 4;
|
||||||
|
if (addr) {
|
||||||
|
tor_addr_to_str(cp, addr, TOR_ADDR_BUF_LEN, 0);
|
||||||
|
} else {
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = htonl(addr32h);
|
||||||
|
tor_inet_ntoa(&in, cp, INET_NTOA_BUF_LEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Use <b>buf</b> (which must be at least NODE_DESC_BUF_LEN bytes long) to
|
||||||
|
* hold a human-readable description of <b>ri</b>.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Return a pointer to the front of <b>buf</b>.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
router_get_description(char *buf, const routerinfo_t *ri)
|
||||||
|
{
|
||||||
|
return format_node_description(buf,
|
||||||
|
ri->cache_info.identity_digest,
|
||||||
|
ri->is_named,
|
||||||
|
ri->nickname,
|
||||||
|
NULL,
|
||||||
|
ri->addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Use <b>buf</b> (which must be at least NODE_DESC_BUF_LEN bytes long) to
|
||||||
|
* hold a human-readable description of <b>rs</b>.
|
||||||
|
*
|
||||||
|
* Return a pointer to the front of <b>buf</b>.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
routerstatus_get_description(char *buf, const routerstatus_t *rs)
|
||||||
|
{
|
||||||
|
return format_node_description(buf,
|
||||||
|
rs->identity_digest,
|
||||||
|
rs->is_named,
|
||||||
|
rs->nickname,
|
||||||
|
NULL,
|
||||||
|
rs->addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Use <b>buf</b> (which must be at least NODE_DESC_BUF_LEN bytes long) to
|
||||||
|
* hold a human-readable description of <b>ei</b>.
|
||||||
|
*
|
||||||
|
* Return a pointer to the front of <b>buf</b>.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
extend_info_get_description(char *buf, const extend_info_t *ei)
|
||||||
|
{
|
||||||
|
return format_node_description(buf,
|
||||||
|
ei->identity_digest,
|
||||||
|
0,
|
||||||
|
ei->nickname,
|
||||||
|
&ei->addr,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a human-readable description of the routerinfo_t <b>ri</b>.
|
||||||
|
*
|
||||||
|
* This function is not thread-safe. Each call to this function invalidates
|
||||||
|
* previous values returned by this function.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
router_describe(const routerinfo_t *ri)
|
||||||
|
{
|
||||||
|
static char buf[NODE_DESC_BUF_LEN];
|
||||||
|
return router_get_description(buf, ri);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a human-readable description of the routerstatus_t <b>rs</b>.
|
||||||
|
*
|
||||||
|
* This function is not thread-safe. Each call to this function invalidates
|
||||||
|
* previous values returned by this function.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
routerstatus_describe(const routerstatus_t *rs)
|
||||||
|
{
|
||||||
|
static char buf[NODE_DESC_BUF_LEN];
|
||||||
|
return routerstatus_get_description(buf, rs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a human-readable description of the extend_info_t <b>ri</b>.
|
||||||
|
*
|
||||||
|
* This function is not thread-safe. Each call to this function invalidates
|
||||||
|
* previous values returned by this function.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
extend_info_describe(const extend_info_t *ei)
|
||||||
|
{
|
||||||
|
static char buf[NODE_DESC_BUF_LEN];
|
||||||
|
return extend_info_get_description(buf, ei);
|
||||||
|
}
|
||||||
|
|
||||||
/** Set <b>buf</b> (which must have MAX_VERBOSE_NICKNAME_LEN+1 bytes) to the
|
/** Set <b>buf</b> (which must have MAX_VERBOSE_NICKNAME_LEN+1 bytes) to the
|
||||||
* verbose representation of the identity of <b>router</b>. The format is:
|
* verbose representation of the identity of <b>router</b>. The format is:
|
||||||
* A dollar sign.
|
* A dollar sign.
|
||||||
|
@ -85,6 +85,21 @@ int extrainfo_dump_to_string(char **s, extrainfo_t *extrainfo,
|
|||||||
int is_legal_nickname(const char *s);
|
int is_legal_nickname(const char *s);
|
||||||
int is_legal_nickname_or_hexdigest(const char *s);
|
int is_legal_nickname_or_hexdigest(const char *s);
|
||||||
int is_legal_hexdigest(const char *s);
|
int is_legal_hexdigest(const char *s);
|
||||||
|
|
||||||
|
#define NODE_DESC_BUF_LEN (MAX_VERBOSE_NICKNAME_LEN+4+TOR_ADDR_BUF_LEN)
|
||||||
|
const char *format_node_description(char *buf,
|
||||||
|
const char *id_digest,
|
||||||
|
int is_named,
|
||||||
|
const char *nickname,
|
||||||
|
const tor_addr_t *addr,
|
||||||
|
uint32_t addr32h);
|
||||||
|
const char *router_get_description(char *buf, const routerinfo_t *ri);
|
||||||
|
const char *routerstatus_get_description(char *buf, const routerstatus_t *rs);
|
||||||
|
const char *extend_info_get_description(char *buf, const extend_info_t *ei);
|
||||||
|
const char *router_describe(const routerinfo_t *ri);
|
||||||
|
const char *routerstatus_describe(const routerstatus_t *ri);
|
||||||
|
const char *extend_info_describe(const extend_info_t *ei);
|
||||||
|
|
||||||
void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
|
void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
|
||||||
void routerstatus_get_verbose_nickname(char *buf,
|
void routerstatus_get_verbose_nickname(char *buf,
|
||||||
const routerstatus_t *router);
|
const routerstatus_t *router);
|
||||||
|
@ -3210,8 +3210,8 @@ router_set_status(const char *digest, int up)
|
|||||||
|
|
||||||
router = router_get_by_digest(digest);
|
router = router_get_by_digest(digest);
|
||||||
if (router) {
|
if (router) {
|
||||||
log_debug(LD_DIR,"Marking router '%s/%s' as %s.",
|
log_debug(LD_DIR,"Marking router %s as %s.",
|
||||||
router->nickname, router->address, up ? "up" : "down");
|
router_describe(router), up ? "up" : "down");
|
||||||
if (!up && router_is_me(router) && !we_are_hibernating())
|
if (!up && router_is_me(router) && !we_are_hibernating())
|
||||||
log_warn(LD_NET, "We just marked ourself as down. Are your external "
|
log_warn(LD_NET, "We just marked ourself as down. Are your external "
|
||||||
"addresses reachable?");
|
"addresses reachable?");
|
||||||
@ -3283,11 +3283,12 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
router->purpose == ROUTER_PURPOSE_BRIDGE &&
|
router->purpose == ROUTER_PURPOSE_BRIDGE &&
|
||||||
!was_bridge) {
|
!was_bridge) {
|
||||||
log_info(LD_DIR, "Replacing non-bridge descriptor with bridge "
|
log_info(LD_DIR, "Replacing non-bridge descriptor with bridge "
|
||||||
"descriptor for router '%s'", router->nickname);
|
"descriptor for router %s",
|
||||||
|
router_describe(router));
|
||||||
} else {
|
} else {
|
||||||
log_info(LD_DIR,
|
log_info(LD_DIR,
|
||||||
"Dropping descriptor that we already have for router '%s'",
|
"Dropping descriptor that we already have for router %s",
|
||||||
router->nickname);
|
router_describe(router));
|
||||||
*msg = "Router descriptor was not new.";
|
*msg = "Router descriptor was not new.";
|
||||||
routerinfo_free(router);
|
routerinfo_free(router);
|
||||||
return ROUTER_WAS_NOT_NEW;
|
return ROUTER_WAS_NOT_NEW;
|
||||||
@ -3311,8 +3312,8 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
/* We asked for it, so some networkstatus must have listed it when we
|
/* We asked for it, so some networkstatus must have listed it when we
|
||||||
* did. Save it if we're a cache in case somebody else asks for it. */
|
* did. Save it if we're a cache in case somebody else asks for it. */
|
||||||
log_info(LD_DIR,
|
log_info(LD_DIR,
|
||||||
"Received a no-longer-recognized descriptor for router '%s'",
|
"Received a no-longer-recognized descriptor for router %s",
|
||||||
router->nickname);
|
router_describe(router));
|
||||||
*msg = "Router descriptor is not referenced by any network-status.";
|
*msg = "Router descriptor is not referenced by any network-status.";
|
||||||
|
|
||||||
/* Only journal this desc if we'll be serving it. */
|
/* Only journal this desc if we'll be serving it. */
|
||||||
@ -3363,8 +3364,9 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
if (router->purpose == ROUTER_PURPOSE_BRIDGE && from_cache &&
|
if (router->purpose == ROUTER_PURPOSE_BRIDGE && from_cache &&
|
||||||
!authdir_mode_bridge(options) &&
|
!authdir_mode_bridge(options) &&
|
||||||
!routerinfo_is_a_configured_bridge(router)) {
|
!routerinfo_is_a_configured_bridge(router)) {
|
||||||
log_info(LD_DIR, "Dropping bridge descriptor for '%s' because we have "
|
log_info(LD_DIR, "Dropping bridge descriptor for %s because we have "
|
||||||
"no bridge configured at that address.", router->nickname);
|
"no bridge configured at that address.",
|
||||||
|
safe_str_client(router_describe(router)));
|
||||||
*msg = "Router descriptor was not a configured bridge.";
|
*msg = "Router descriptor was not a configured bridge.";
|
||||||
routerinfo_free(router);
|
routerinfo_free(router);
|
||||||
return ROUTER_WAS_NOT_WANTED;
|
return ROUTER_WAS_NOT_WANTED;
|
||||||
@ -3375,8 +3377,8 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
if (!in_consensus && (router->cache_info.published_on <=
|
if (!in_consensus && (router->cache_info.published_on <=
|
||||||
old_router->cache_info.published_on)) {
|
old_router->cache_info.published_on)) {
|
||||||
/* Same key, but old. This one is not listed in the consensus. */
|
/* Same key, but old. This one is not listed in the consensus. */
|
||||||
log_debug(LD_DIR, "Not-new descriptor for router '%s'",
|
log_debug(LD_DIR, "Not-new descriptor for router %s",
|
||||||
router->nickname);
|
router_describe(router));
|
||||||
/* Only journal this desc if we'll be serving it. */
|
/* Only journal this desc if we'll be serving it. */
|
||||||
if (!from_cache && should_cache_old_descriptors())
|
if (!from_cache && should_cache_old_descriptors())
|
||||||
signed_desc_append_to_journal(&router->cache_info,
|
signed_desc_append_to_journal(&router->cache_info,
|
||||||
@ -3386,9 +3388,8 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
return ROUTER_WAS_NOT_NEW;
|
return ROUTER_WAS_NOT_NEW;
|
||||||
} else {
|
} else {
|
||||||
/* Same key, and either new, or listed in the consensus. */
|
/* Same key, and either new, or listed in the consensus. */
|
||||||
log_debug(LD_DIR, "Replacing entry for router '%s/%s' [%s]",
|
log_debug(LD_DIR, "Replacing entry for router %s",
|
||||||
router->nickname, old_router->nickname,
|
router_describe(router));
|
||||||
hex_str(id_digest,DIGEST_LEN));
|
|
||||||
if (routers_have_same_or_addr(router, old_router)) {
|
if (routers_have_same_or_addr(router, old_router)) {
|
||||||
/* these carry over when the address and orport are unchanged. */
|
/* these carry over when the address and orport are unchanged. */
|
||||||
router->last_reachable = old_router->last_reachable;
|
router->last_reachable = old_router->last_reachable;
|
||||||
@ -3664,8 +3665,8 @@ routerlist_remove_old_routers(void)
|
|||||||
/* Too old: remove it. (If we're a cache, just move it into
|
/* Too old: remove it. (If we're a cache, just move it into
|
||||||
* old_routers.) */
|
* old_routers.) */
|
||||||
log_info(LD_DIR,
|
log_info(LD_DIR,
|
||||||
"Forgetting obsolete (too old) routerinfo for router '%s'",
|
"Forgetting obsolete (too old) routerinfo for router %s",
|
||||||
router->nickname);
|
router_describe(router));
|
||||||
routerlist_remove(routerlist, router, 1, now);
|
routerlist_remove(routerlist, router, 1, now);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
@ -4585,7 +4586,8 @@ update_consensus_router_descriptor_downloads(time_t now, int is_vote,
|
|||||||
if (oldrouter)
|
if (oldrouter)
|
||||||
format_iso_time(time_bufold, oldrouter->cache_info.published_on);
|
format_iso_time(time_bufold, oldrouter->cache_info.published_on);
|
||||||
log_info(LD_DIR, "Learned about %s (%s vs %s) from %s's vote (%s)",
|
log_info(LD_DIR, "Learned about %s (%s vs %s) from %s's vote (%s)",
|
||||||
rs->nickname, time_bufnew,
|
routerstatus_describe(rs),
|
||||||
|
time_bufnew,
|
||||||
oldrouter ? time_bufold : "none",
|
oldrouter ? time_bufold : "none",
|
||||||
source->nickname, oldrouter ? "known" : "unknown");
|
source->nickname, oldrouter ? "known" : "unknown");
|
||||||
}
|
}
|
||||||
|
@ -1210,7 +1210,8 @@ router_parse_list_from_string(const char **s, const char *eos,
|
|||||||
prepend_annotations);
|
prepend_annotations);
|
||||||
if (router) {
|
if (router) {
|
||||||
log_debug(LD_DIR, "Read router '%s', purpose '%s'",
|
log_debug(LD_DIR, "Read router '%s', purpose '%s'",
|
||||||
router->nickname, router_purpose_to_string(router->purpose));
|
router_describe(router),
|
||||||
|
router_purpose_to_string(router->purpose));
|
||||||
signed_desc = &router->cache_info;
|
signed_desc = &router->cache_info;
|
||||||
elt = router;
|
elt = router;
|
||||||
}
|
}
|
||||||
@ -2488,7 +2489,7 @@ networkstatus_verify_bw_weights(networkstatus_t *ns)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_warn(LD_BUG, "Missing consensus bandwidth for router %s",
|
log_warn(LD_BUG, "Missing consensus bandwidth for router %s",
|
||||||
rs->nickname);
|
routerstatus_describe(rs));
|
||||||
}
|
}
|
||||||
} SMARTLIST_FOREACH_END(rs);
|
} SMARTLIST_FOREACH_END(rs);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user