aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-30 15:41:46 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-30 15:41:46 -0400
commitfa1d47293b62fd378a7e43cf3ce3e7bb3be884e3 (patch)
treeb80ab67323274c8ae1e2f8097278e923c5d5d243 /src/or
parent21de9d46e264ceb14f3fe59d17210d82f2499637 (diff)
parent7f0fb8e6083128ff20b30d8cd29c220e9427d95e (diff)
downloadtor-fa1d47293b62fd378a7e43cf3ce3e7bb3be884e3.tar
tor-fa1d47293b62fd378a7e43cf3ce3e7bb3be884e3.tar.gz
Merge remote-tracking branch 'origin/maint-0.2.2'
The conflicts were mainly caused by the routerinfo->node transition. Conflicts: src/or/circuitbuild.c src/or/command.c src/or/connection_edge.c src/or/directory.c src/or/dirserv.c src/or/relay.c src/or/rendservice.c src/or/routerlist.c
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuitbuild.c44
-rw-r--r--src/or/circuitlist.c6
-rw-r--r--src/or/circuituse.c4
-rw-r--r--src/or/command.c4
-rw-r--r--src/or/connection_edge.c6
-rw-r--r--src/or/directory.c7
-rw-r--r--src/or/dirserv.c47
-rw-r--r--src/or/relay.c5
-rw-r--r--src/or/rendclient.c19
-rw-r--r--src/or/rendservice.c31
-rw-r--r--src/or/rephist.c6
-rw-r--r--src/or/router.c180
-rw-r--r--src/or/router.h24
-rw-r--r--src/or/routerlist.c38
-rw-r--r--src/or/routerlist.h1
-rw-r--r--src/or/routerparse.c5
16 files changed, 331 insertions, 96 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 34bb1fd06..8140cc4c4 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1748,10 +1748,9 @@ circuit_handle_first_hop(origin_circuit_t *circ)
if (!n_conn) {
/* 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",
- 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);
if (should_launch) {
@@ -2034,7 +2033,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
log_info(LD_CIRC,"First hop: finished sending %s cell to '%s'",
fast ? "CREATE_FAST" : "CREATE",
- node ? node_get_nickname(node) : "<unnamed>");
+ node ? node_describe(node) : "<unnamed>");
} else {
tor_assert(circ->cpath->state == CPATH_STATE_OPEN);
tor_assert(circ->_base.state == CIRCUIT_STATE_BUILDING);
@@ -2818,7 +2817,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
tor_free(n_supported);
if (node) {
- log_info(LD_CIRC, "Chose exit server '%s'", node_get_nickname(node));
+ log_info(LD_CIRC, "Chose exit server '%s'", node_describe(node));
return node;
}
if (options->ExitNodes) {
@@ -2925,7 +2924,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, "
"even though StrictNodes is set. Please report. "
"(Circuit purpose: %s)",
- description, exit->nickname,
+ description, extend_info_describe(exit),
rs==options->ExcludeNodes?"":" or ExcludeExitNodes",
circuit_purpose_to_string(purpose));
} else {
@@ -2934,7 +2933,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
"prevent this (and possibly break your Tor functionality), "
"set the StrictNodes configuration option. "
"(Circuit purpose: %s)",
- description, exit->nickname,
+ description, extend_info_describe(exit),
rs==options->ExcludeNodes?"":" or ExcludeExitNodes",
circuit_purpose_to_string(purpose));
}
@@ -2964,7 +2963,8 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
if (exit) { /* the circuit-builder pre-requested one */
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);
} else { /* we have to decide one */
const node_t *node =
@@ -3014,8 +3014,8 @@ circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *exit)
circuit_append_new_exit(circ, exit);
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
if ((err_reason = circuit_send_next_onion_skin(circ))<0) {
- log_warn(LD_CIRC, "Couldn't extend circuit to new point '%s'.",
- exit->nickname);
+ log_warn(LD_CIRC, "Couldn't extend circuit to new point %s.",
+ extend_info_describe(exit));
circuit_mark_for_close(TO_CIRCUIT(circ), -err_reason);
return -1;
}
@@ -3239,7 +3239,8 @@ onion_extend_cpath(origin_circuit_t *circ)
}
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);
extend_info_free(info);
@@ -3541,20 +3542,24 @@ log_entry_guards(int severity)
smartlist_t *elements = smartlist_create();
char *s;
- SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e,
+ SMARTLIST_FOREACH_BEGIN(entry_guards, entry_guard_t *, e)
{
const char *msg = NULL;
char *cp;
if (entry_is_live(e, 0, 1, 0, &msg))
- tor_asprintf(&cp, "%s (up %s)",
+ tor_asprintf(&cp, "%s [%s] (up %s)",
e->nickname,
+ hex_str(e->identity, DIGEST_LEN),
e->made_contact ? "made-contact" : "never-contacted");
else
- tor_asprintf(&cp, "%s (%s, %s)",
- e->nickname, msg,
+ tor_asprintf(&cp, "%s [%s] (%s, %s)",
+ e->nickname,
+ hex_str(e->identity, DIGEST_LEN),
+ msg,
e->made_contact ? "made-contact" : "never-contacted");
smartlist_add(elements, cp);
- });
+ }
+ SMARTLIST_FOREACH_END(e);
s = smartlist_join_strings(elements, ",", 0, NULL);
SMARTLIST_FOREACH(elements, char*, cp, tor_free(cp));
@@ -3622,8 +3627,8 @@ add_an_entry_guard(const node_t *chosen, int reset_status)
return NULL;
}
entry = tor_malloc_zero(sizeof(entry_guard_t));
- log_info(LD_CIRC, "Chose '%s' as new entry guard.",
- node_get_nickname(node));
+ log_info(LD_CIRC, "Chose %s as new entry guard.",
+ node_describe(node));
strlcpy(entry->nickname, node_get_nickname(node), sizeof(entry->nickname));
memcpy(entry->identity, node->identity, DIGEST_LEN);
/* Choose expiry time smudged over the past month. The goal here
@@ -3813,8 +3818,9 @@ entry_guards_compute_status(or_options_t *options, time_t now)
const char *reason = digestmap_get(reasons, entry->identity);
const char *live_msg = "";
const node_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,
+ hex_str(entry->identity, DIGEST_LEN),
entry->unreachable_since ? "unreachable" : "reachable",
entry->bad_since ? "unusable" : "usable",
reason ? ", ": "",
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 7c5fd2570..f1f0cb2a6 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -272,8 +272,10 @@ circuit_count_pending_on_or_conn(or_connection_t *or_conn)
circuit_get_all_pending_on_or_conn(sl, or_conn);
cnt = smartlist_len(sl);
smartlist_free(sl);
- log_debug(LD_CIRC,"or_conn to %s, %d pending circs",
- or_conn->nickname ? or_conn->nickname : "NULL", cnt);
+ log_debug(LD_CIRC,"or_conn to %s at %s, %d pending circs",
+ or_conn->nickname ? or_conn->nickname : "NULL",
+ or_conn->_base.address,
+ cnt);
return cnt;
}
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index f7274bd16..dddf6a29a 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -1317,8 +1317,8 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
conn->_base.state = AP_CONN_STATE_RENDDESC_WAIT;
return 0;
}
- log_info(LD_REND,"Chose '%s' as intro point for '%s'.",
- extend_info->nickname,
+ log_info(LD_REND,"Chose %s as intro point for '%s'.",
+ extend_info_describe(extend_info),
safe_str_client(conn->rend_data->onion_address));
}
diff --git a/src/or/command.c b/src/or/command.c
index 994bc86a1..d24373eec 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -276,8 +276,8 @@ command_process_create_cell(cell_t *cell, or_connection_t *conn)
if (node) {
char *p = esc_for_log(node_get_platform(node));
log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
- "Details: nickname \"%s\", platform %s.",
- node_get_nickname(node), p);
+ "Details: router %s, platform %s.",
+ node_describe(node), p);
tor_free(p);
}
return;
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index ec3b41744..273a962bb 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -503,12 +503,12 @@ connection_ap_expire_beginning(void)
}
tor_assert(circ->purpose == CIRCUIT_PURPOSE_C_GENERAL);
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.",
seconds_idle,
safe_str_client(conn->socks_request->address),
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 */
connection_edge_end(conn, END_STREAM_REASON_TIMEOUT);
/* un-mark it as ending, since we're going to reuse it */
@@ -1830,7 +1830,7 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
if (r) {
log_info(LD_APP,
"Redirecting address %s to exit at enclave router %s",
- safe_str_client(socks->address), node_get_nickname(r));
+ safe_str_client(socks->address), node_describe(r));
/* use the hex digest, not nickname, in case there are two
routers with this nickname */
conn->chosen_exit_name =
diff --git a/src/or/directory.c b/src/or/directory.c
index 810612cd6..e7a2a4b83 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -558,7 +558,8 @@ directory_initiate_command_routerstatus_rend(const routerstatus_t *status,
if (!node && anonymized_connection) {
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;
} else if (node) {
node_get_address_string(node, address_buf, sizeof(address_buf));
@@ -572,10 +573,10 @@ directory_initiate_command_routerstatus_rend(const routerstatus_t *status,
if (options->ExcludeNodes && options->StrictNodes &&
routerset_contains_routerstatus(options->ExcludeNodes, status, -1)) {
- 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. "
"Skipping. This choice might make your Tor not work.",
- status->nickname,
+ routerstatus_describe(status),
dir_conn_purpose_to_string(dir_purpose));
return;
}
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index aa2e74b0b..c591d906e 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -518,14 +518,15 @@ dirserv_router_has_valid_address(routerinfo_t *ri)
if (get_options()->DirAllowPrivateAddresses)
return 0; /* whatever it is, we're fine with it */
if (!tor_inet_aton(ri->address, &iaddr)) {
- log_info(LD_DIRSERV,"Router '%s' published non-IP address '%s'. Refusing.",
- ri->nickname, ri->address);
+ log_info(LD_DIRSERV,"Router %s published non-IP address '%s'. Refusing.",
+ router_describe(ri),
+ ri->address);
return -1;
}
if (is_internal_IP(ntohl(iaddr.s_addr), 0)) {
log_info(LD_DIRSERV,
- "Router '%s' published internal IP address '%s'. Refusing.",
- ri->nickname, ri->address);
+ "Router %s published internal IP address '%s'. Refusing.",
+ router_describe(ri), ri->address);
return -1; /* it's a private IP, we should reject it */
}
return 0;
@@ -554,10 +555,11 @@ authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
/* Is there too much clock skew? */
now = time(NULL);
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 "
"(%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));
*msg = "Rejected: Your clock is set too far in the future, or your "
"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) {
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)",
- 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));
*msg = "Rejected: Server is expired, or your clock is too far in the past,"
" 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) {
log_fn(severity, LD_DIRSERV,
- "Router with nickname '%s' has invalid address '%s'. "
+ "Router %s has invalid address '%s'. "
"Not adding (%s).",
- ri->nickname, ri->address,
+ router_describe(ri),
+ ri->address,
esc_router_info(ri));
*msg = "Rejected: Address is not an IP, or IP is a private address.";
return -1;
@@ -729,9 +733,9 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)
&& router_differences_are_cosmetic(ri_old, ri)
&& !router_is_me(ri)) {
log_info(LD_DIRSERV,
- "Not replacing descriptor from '%s' (source: %s); "
+ "Not replacing descriptor from %s (source: %s); "
"differences are cosmetic.",
- ri->nickname, source);
+ router_describe(ri), source);
*msg = "Not replacing router descriptor; no information has changed since "
"the last one with this identity.";
control_event_or_authdir_new_descriptor("DROPPED",
@@ -831,13 +835,15 @@ directory_remove_invalid(void)
SMARTLIST_FOREACH_BEGIN(nodes, node_t *, node) {
const char *msg;
routerinfo_t *ent = node->ri;
+ char description[NODE_DESC_BUF_LEN];
uint32_t r;
if (!ent)
continue;
r = dirserv_router_get_status(ent, &msg);
+ router_get_description(description, ent);
if (r & FP_REJECT) {
- log_info(LD_DIRSERV, "Router '%s' is now rejected: %s",
- ent->nickname, msg?msg:"");
+ log_info(LD_DIRSERV, "Router %s is now rejected: %s",
+ description, msg?msg:"");
routerlist_remove(rl, ent, 0, time(NULL));
changed = 1;
continue;
@@ -845,33 +851,33 @@ directory_remove_invalid(void)
#if 0
if (bool_neq((r & FP_NAMED), ent->auth_says_is_named)) {
log_info(LD_DIRSERV,
- "Router '%s' is now %snamed.", ent->nickname,
+ "Router %s is now %snamed.", description,
(r&FP_NAMED)?"":"un");
ent->is_named = (r&FP_NAMED)?1:0;
changed = 1;
}
if (bool_neq((r & FP_UNNAMED), ent->auth_says_is_unnamed)) {
log_info(LD_DIRSERV,
- "Router '%s' is now %snamed. (FP_UNNAMED)", ent->nickname,
+ "Router '%s' is now %snamed. (FP_UNNAMED)", description,
(r&FP_NAMED)?"":"un");
ent->is_named = (r&FP_NUNAMED)?0:1;
changed = 1;
}
#endif
if (bool_neq((r & FP_INVALID), !node->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" : "");
node->is_valid = (r&FP_INVALID)?0:1;
changed = 1;
}
if (bool_neq((r & FP_BADDIR), node->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");
node->is_bad_directory = (r&FP_BADDIR) ? 1: 0;
changed = 1;
}
if (bool_neq((r & FP_BADEXIT), node->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");
node->is_bad_exit = (r&FP_BADEXIT) ? 1: 0;
changed = 1;
@@ -3191,7 +3197,8 @@ dirserv_orconn_tls_done(const char *address,
if (!bridge_auth || ri->purpose == ROUTER_PURPOSE_BRIDGE) {
tor_addr_t addr, *addrp=NULL;
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)
addrp = &addr;
else
diff --git a/src/or/relay.c b/src/or/relay.c
index cf531169e..28f940c48 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -29,6 +29,7 @@
#include "reasons.h"
#include "relay.h"
#include "rendcommon.h"
+#include "router.h"
#include "routerlist.h"
#include "routerparse.h"
@@ -751,9 +752,9 @@ connection_ap_process_end_not_open(
(tor_inet_aton(conn->socks_request->address, &in) &&
!conn->chosen_exit_name))) {
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.",
- node_get_nickname(exitrouter));
+ node_describe(exitrouter));
policies_set_node_exitpolicy_to_reject_all(exitrouter);
}
/* rewrite it to an IP if we learned one. */
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index d135dc53f..67d246acf 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -21,6 +21,7 @@
#include "rendclient.h"
#include "rendcommon.h"
#include "rephist.h"
+#include "router.h"
#include "routerlist.h"
static extend_info_t *rend_client_get_random_intro_impl(
@@ -91,12 +92,13 @@ rend_client_reextend_intro_circuit(origin_circuit_t *circ)
if (circ->remaining_relay_early_cells) {
log_info(LD_REND,
"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);
} else {
log_info(LD_REND,
"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);
if (!circuit_launch_by_extend_info(CIRCUIT_PURPOSE_C_INTRODUCING,
extend_info,
@@ -169,7 +171,8 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
"have a v2 rend desc with %d intro points. "
"Trying a different intro point...",
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));
if (rend_client_reextend_intro_circuit(introcirc)) {
@@ -352,8 +355,8 @@ rend_client_introduction_acked(origin_circuit_t *circ,
* If none remain, refetch the service descriptor.
*/
log_info(LD_REND, "Got nack for %s from %s...",
- safe_str_client(circ->rend_data->onion_address),
- circ->build_state->chosen_exit->nickname);
+ safe_str_client(circ->rend_data->onion_address),
+ safe_str_client(extend_info_describe(circ->build_state->chosen_exit)));
if (rend_client_remove_intro_point(circ->build_state->chosen_exit,
circ->rend_data) > 0) {
/* There are introduction points left. Re-extend the circuit to
@@ -508,12 +511,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 "
"service '%s' with descriptor ID '%s', auth type %d, "
"and descriptor cookie '%s' to hidden service "
- "directory '%s' on port %d.",
+ "directory %s",
rend_query->onion_address, desc_id_base32,
rend_query->auth_type,
(rend_query->auth_type == REND_NO_AUTH ? "[none]" :
- escaped_safe_str_client(descriptor_cookie_base64)),
- hs_dir->nickname, hs_dir->dir_port);
+ escaped_safe_str_client(descriptor_cookie_base64)),
+ routerstatus_describe(hs_dir));
return 1;
}
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 3d5c80c23..fa81fb3d0 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -475,7 +475,8 @@ rend_config_services(or_options_t *options, int validate_only)
if (keep_it)
continue;
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);
circuit_mark_for_close(circ, END_CIRC_REASON_FINISHED);
/* XXXX Is there another reason we should use here? */
@@ -1147,7 +1148,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
if (!launched) { /* give up */
log_warn(LD_REND, "Giving up launching first hop of circuit to rendezvous "
"point %s for service %s.",
- escaped_safe_str_client(extend_info->nickname),
+ safe_str_client(extend_info_describe(extend_info)),
serviceid);
reason = END_CIRC_REASON_CONNECTFAILED;
goto err;
@@ -1155,7 +1156,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
log_info(LD_REND,
"Accepted intro; launching circuit to %s "
"(cookie %s) for service %s.",
- escaped_safe_str_client(extend_info->nickname),
+ safe_str_client(extend_info_describe(extend_info)),
hexcookie, serviceid);
tor_assert(launched->build_state);
/* Fill in the circuit's state. */
@@ -1207,7 +1208,8 @@ rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc)
"Attempt to build circuit to %s for rendezvous has failed "
"too many times or expired; giving up.",
oldcirc->build_state ?
- oldcirc->build_state->chosen_exit->nickname : "*unknown*");
+ safe_str(extend_info_describe(oldcirc->build_state->chosen_exit))
+ : "*unknown*");
return;
}
@@ -1221,7 +1223,7 @@ rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc)
}
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,
oldstate->chosen_exit,
@@ -1229,7 +1231,7 @@ rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc)
if (!newcirc) {
log_warn(LD_REND,"Couldn't relaunch rendezvous circuit to '%s'.",
- oldstate->chosen_exit->nickname);
+ safe_str(extend_info_describe(oldstate->chosen_exit)));
return;
}
newstate = newcirc->build_state;
@@ -1253,7 +1255,7 @@ rend_service_launch_establish_intro(rend_service_t *service,
log_info(LD_REND,
"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);
rep_hist_note_used_internal(time(NULL), 1, 0);
@@ -1266,7 +1268,7 @@ rend_service_launch_establish_intro(rend_service_t *service,
if (!launched) {
log_info(LD_REND,
"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;
}
@@ -1609,9 +1611,9 @@ directory_post_to_hs_dir(rend_service_descriptor_t *renddesc,
continue;
if (!router_get_by_id_digest(hs_dir->identity_digest)) {
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.",
- hs_dir->nickname);
+ safe_str_client(routerstatus_describe(hs_dir)));
failed_upload = -1;
continue;
}
@@ -1819,7 +1821,8 @@ rend_services_introduce(void)
node = node_get_by_id(intro->extend_info->identity_digest);
if (!node || !find_intro_circuit(intro, service->pk_digest)) {
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) {
SMARTLIST_FOREACH(service->desc->intro_nodes, rend_intro_point_t *,
dintro, {
@@ -1885,7 +1888,8 @@ rend_services_introduce(void)
tor_assert(!crypto_pk_generate_key(intro->intro_key));
smartlist_add(service->intro_nodes, intro);
log_info(LD_REND, "Picked router %s as an intro point for %s.",
- node_get_nickname(node), service->service_id);
+ safe_str_client(node_describe(node)),
+ safe_str_client(service->service_id));
}
/* If there's no need to launch new circuits, stop here. */
@@ -1898,7 +1902,8 @@ rend_services_introduce(void)
r = rend_service_launch_establish_intro(service, intro);
if (r<0) {
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));
}
}
}
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 1ab4171a5..8f359c717 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -635,6 +635,7 @@ rep_hist_dump_stats(time_t now, int severity)
digestmap_iter_t *orhist_it;
const char *name1, *name2, *digest1, *digest2;
char hexdigest1[HEX_DIGEST_LEN+1];
+ char hexdigest2[HEX_DIGEST_LEN+1];
or_history_t *or_history;
link_history_t *link_history;
void *or_history_p, *link_history_p;
@@ -695,7 +696,10 @@ rep_hist_dump_stats(time_t now, int severity)
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_fail);
if (ret<0)
diff --git a/src/or/router.c b/src/or/router.c
index 2b11a5202..73fabefb3 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -2235,6 +2235,186 @@ is_legal_hexdigest(const char *s)
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 0.
+ *
+ * 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;
+
+ if (!buf)
+ return "<NULL BUFFER>";
+
+ 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)
+{
+ if (!ri)
+ return "<null>";
+ return format_node_description(buf,
+ ri->cache_info.identity_digest,
+ router_is_named(ri),
+ 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>node</b>.
+ *
+ * Return a pointer to the front of <b>buf</b>.
+ */
+const char *
+node_get_description(char *buf, const node_t *node)
+{
+ const char *nickname = NULL;
+ uint32_t addr32h = 0;
+ int is_named = 0;
+
+ if (!node)
+ return "<null>";
+
+ if (node->rs) {
+ nickname = node->rs->nickname;
+ is_named = node->rs->is_named;
+ addr32h = node->rs->addr;
+ } else if (node->ri) {
+ nickname = node->ri->nickname;
+ addr32h = node->ri->addr;
+ }
+
+ return format_node_description(buf,
+ node->identity,
+ is_named,
+ nickname,
+ NULL,
+ addr32h);
+}
+
+/** 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)
+{
+ if (!rs)
+ return "<null>";
+ 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)
+{
+ if (!ei)
+ return "<null>";
+ 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 node_t <b>node</b>.
+ *
+ * This function is not thread-safe. Each call to this function invalidates
+ * previous values returned by this function.
+ */
+const char *
+node_describe(const node_t *node)
+{
+ static char buf[NODE_DESC_BUF_LEN];
+ return node_get_description(buf, node);
+}
+
+/** 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
* verbose representation of the identity of <b>router</b>. The format is:
* A dollar sign.
diff --git a/src/or/router.h b/src/or/router.h
index 2e5d44f35..e208eb122 100644
--- a/src/or/router.h
+++ b/src/or/router.h
@@ -85,6 +85,30 @@ int extrainfo_dump_to_string(char **s, extrainfo_t *extrainfo,
int is_legal_nickname(const char *s);
int is_legal_nickname_or_hexdigest(const char *s);
int is_legal_hexdigest(const char *s);
+
+/**
+ * Longest allowed output of format_node_description, plus 1 character for
+ * NUL. This allows space for:
+ * "$FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF~xxxxxxxxxxxxxxxxxxx at"
+ * " [ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]"
+ * plus a terminating NUL.
+ */
+#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 *node_get_description(char *buf, const node_t *node);
+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 *node_describe(const node_t *node);
+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 routerstatus_get_verbose_nickname(char *buf,
const routerstatus_t *router);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 5ce50aa46..a8a597421 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2285,7 +2285,7 @@ hex_digest_nickname_matches(const char *hexdigest, const char *identity_digest,
/* Return true iff <b>router</b> is listed as named in the current
* consensus. */
-static int
+int
router_is_named(const routerinfo_t *router)
{
const char *digest =
@@ -3230,10 +3230,8 @@ router_set_status(const char *digest, int up)
node = node_get_mutable_by_id(digest);
if (node) {
#if 0
- char buf[MAX_VERBOSE_NICKNAME_LEN+1];
- node_get_verbose_nickname(node,buf);
log_debug(LD_DIR,"Marking router %s as %s.",
- buf, up ? "up" : "down");
+ node_describe(node), up ? "up" : "down");
#endif
if (!up && node_is_me(node) && !we_are_hibernating())
log_warn(LD_NET, "We just marked ourself as down. Are your external "
@@ -3302,11 +3300,12 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
router->purpose == ROUTER_PURPOSE_BRIDGE &&
!was_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 {
log_info(LD_DIR,
- "Dropping descriptor that we already have for router '%s'",
- router->nickname);
+ "Dropping descriptor that we already have for router %s",
+ router_describe(router));
*msg = "Router descriptor was not new.";
routerinfo_free(router);
return ROUTER_WAS_NOT_NEW;
@@ -3330,8 +3329,8 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
/* 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. */
log_info(LD_DIR,
- "Received a no-longer-recognized descriptor for router '%s'",
- router->nickname);
+ "Received a no-longer-recognized descriptor for router %s",
+ router_describe(router));
*msg = "Router descriptor is not referenced by any network-status.";
/* Only journal this desc if we'll be serving it. */
@@ -3383,8 +3382,9 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
if (router->purpose == ROUTER_PURPOSE_BRIDGE && from_cache &&
!authdir_mode_bridge(options) &&
!routerinfo_is_a_configured_bridge(router)) {
- log_info(LD_DIR, "Dropping bridge descriptor for '%s' because we have "
- "no bridge configured at that address.", router->nickname);
+ log_info(LD_DIR, "Dropping bridge descriptor for %s because we have "
+ "no bridge configured at that address.",
+ safe_str_client(router_describe(router)));
*msg = "Router descriptor was not a configured bridge.";
routerinfo_free(router);
return ROUTER_WAS_NOT_WANTED;
@@ -3395,8 +3395,8 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
if (!in_consensus && (router->cache_info.published_on <=
old_router->cache_info.published_on)) {
/* Same key, but old. This one is not listed in the consensus. */
- log_debug(LD_DIR, "Not-new descriptor for router '%s'",
- router->nickname);
+ log_debug(LD_DIR, "Not-new descriptor for router %s",
+ router_describe(router));
/* Only journal this desc if we'll be serving it. */
if (!from_cache && should_cache_old_descriptors())
signed_desc_append_to_journal(&router->cache_info,
@@ -3406,9 +3406,8 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
return ROUTER_WAS_NOT_NEW;
} else {
/* Same key, and either new, or listed in the consensus. */
- log_debug(LD_DIR, "Replacing entry for router '%s/%s' [%s]",
- router->nickname, old_router->nickname,
- hex_str(id_digest,DIGEST_LEN));
+ log_debug(LD_DIR, "Replacing entry for router %s",
+ router_describe(router));
if (routers_have_same_or_addr(router, old_router)) {
/* these carry over when the address and orport are unchanged. */
router->last_reachable = old_router->last_reachable;
@@ -3684,8 +3683,8 @@ routerlist_remove_old_routers(void)
/* Too old: remove it. (If we're a cache, just move it into
* old_routers.) */
log_info(LD_DIR,
- "Forgetting obsolete (too old) routerinfo for router '%s'",
- router->nickname);
+ "Forgetting obsolete (too old) routerinfo for router %s",
+ router_describe(router));
routerlist_remove(routerlist, router, 1, now);
i--;
}
@@ -4668,7 +4667,8 @@ update_consensus_router_descriptor_downloads(time_t now, int is_vote,
if (oldrouter)
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)",
- rs->nickname, time_bufnew,
+ routerstatus_describe(rs),
+ time_bufnew,
oldrouter ? time_bufold : "none",
source->nickname, oldrouter ? "known" : "unknown");
}
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
index a613c34b8..3a8af6fd9 100644
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@ -56,6 +56,7 @@ const node_t *router_choose_random_node(smartlist_t *excludedsmartlist,
const routerinfo_t *router_get_by_nickname(const char *nickname,
int warn_if_unnamed);
+int router_is_named(const routerinfo_t *router);
int router_digest_is_trusted_dir_type(const char *digest,
dirinfo_type_t type);
#define router_digest_is_trusted_dir(d) \
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 295b74dc2..d8045aefc 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1208,7 +1208,8 @@ router_parse_list_from_string(const char **s, const char *eos,
prepend_annotations);
if (router) {
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;
elt = router;
}
@@ -2502,7 +2503,7 @@ networkstatus_verify_bw_weights(networkstatus_t *ns)
}
} else {
log_warn(LD_BUG, "Missing consensus bandwidth for router %s",
- rs->nickname);
+ routerstatus_describe(rs));
}
} SMARTLIST_FOREACH_END(rs);