make circuit building and router parsing less noisy

svn:r3068
This commit is contained in:
Roger Dingledine 2004-12-04 00:25:54 +00:00
parent f79a7d8d62
commit 8d69dc472b
2 changed files with 35 additions and 35 deletions

View File

@ -563,15 +563,15 @@ int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data, int reverse)
tor_assert(!(cpath->f_crypto || cpath->b_crypto ||
cpath->f_digest || cpath->b_digest));
log_fn(LOG_DEBUG,"hop init digest forward 0x%.8x, backward 0x%.8x.",
(unsigned int)*(uint32_t*)key_data, (unsigned int)*(uint32_t*)(key_data+20));
// log_fn(LOG_DEBUG,"hop init digest forward 0x%.8x, backward 0x%.8x.",
// (unsigned int)*(uint32_t*)key_data, (unsigned int)*(uint32_t*)(key_data+20));
cpath->f_digest = crypto_new_digest_env();
crypto_digest_add_bytes(cpath->f_digest, key_data, DIGEST_LEN);
cpath->b_digest = crypto_new_digest_env();
crypto_digest_add_bytes(cpath->b_digest, key_data+DIGEST_LEN, DIGEST_LEN);
log_fn(LOG_DEBUG,"hop init cipher forward 0x%.8x, backward 0x%.8x.",
(unsigned int)*(uint32_t*)(key_data+40), (unsigned int)*(uint32_t*)(key_data+40+16));
// log_fn(LOG_DEBUG,"hop init cipher forward 0x%.8x, backward 0x%.8x.",
// (unsigned int)*(uint32_t*)(key_data+40), (unsigned int)*(uint32_t*)(key_data+40+16));
if (!(cpath->f_crypto =
crypto_create_init_cipher(key_data+(2*DIGEST_LEN),1))) {
log(LOG_WARN,"forward cipher initialization failed.");
@ -825,8 +825,8 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
!circuit_stream_is_being_handled(carray[i]))
++n_pending_connections;
}
log_fn(LOG_DEBUG, "Choosing exit node; %d connections are pending",
n_pending_connections);
// log_fn(LOG_DEBUG, "Choosing exit node; %d connections are pending",
// n_pending_connections);
/* Now we count, for each of the routers in the directory, how many
* of the pending connections could possibly exit from that
* router (n_supported[i]). (We can't be sure about cases where we
@ -837,7 +837,7 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
router = smartlist_get(dir->routers, i);
if (router_is_me(router)) {
n_supported[i] = -1;
log_fn(LOG_DEBUG,"Skipping node %s -- it's me.", router->nickname);
// log_fn(LOG_DEBUG,"Skipping node %s -- it's me.", router->nickname);
/* XXX there's probably a reverse predecessor attack here, but
* it's slow. should we take this out? -RD
*/
@ -845,8 +845,8 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
}
if (!router->is_running) {
n_supported[i] = -1;
log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- directory says it's not running.",
router->nickname, i);
// log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- directory says it's not running.",
// router->nickname, i);
continue; /* skip routers that are known to be down */
}
if (!router->is_verified &&
@ -854,20 +854,20 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
router_is_unreliable_router(router, 1, 1))) {
/* if it's unverified, and either we don't want it or it's unsuitable */
n_supported[i] = -1;
log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- unverified router.",
router->nickname, i);
// log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- unverified router.",
// router->nickname, i);
continue; /* skip unverified routers */
}
if (router_exit_policy_rejects_all(router)) {
n_supported[i] = -1;
log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- it rejects all.",
router->nickname, i);
// log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- it rejects all.",
// router->nickname, i);
continue; /* skip routers that reject all */
}
if (smartlist_len(preferredentries)==1 &&
router == (routerinfo_t*)smartlist_get(preferredentries, 0)) {
n_supported[i] = -1;
log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- it's our only preferred entry node.", router->nickname, i);
// log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- it's our only preferred entry node.", router->nickname, i);
continue;
}
n_supported[i] = 0;
@ -879,19 +879,19 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
continue; /* Skip everything but APs in CIRCUIT_WAIT */
if (connection_ap_can_use_exit(carray[j], router)) {
++n_supported[i];
log_fn(LOG_DEBUG,"%s is supported. n_supported[%d] now %d.",
router->nickname, i, n_supported[i]);
// log_fn(LOG_DEBUG,"%s is supported. n_supported[%d] now %d.",
// router->nickname, i, n_supported[i]);
} else {
log_fn(LOG_DEBUG,"%s (index %d) would reject this stream.",
router->nickname, i);
// log_fn(LOG_DEBUG,"%s (index %d) would reject this stream.",
// router->nickname, i);
}
} /* End looping over connections. */
if (n_supported[i] > best_support) {
/* If this router is better than previous ones, remember its index
* and goodness, and start counting how many routers are this good. */
best_support = n_supported[i]; n_best_support=1;
log_fn(LOG_DEBUG,"%s is new best supported option so far.",
router->nickname);
// log_fn(LOG_DEBUG,"%s is new best supported option so far.",
// router->nickname);
} else if (n_supported[i] == best_support) {
/* If this router is _as good_ as the best one, just increment the
* count of equally good routers.*/
@ -1032,19 +1032,19 @@ static int count_acceptable_routers(smartlist_t *routers) {
n = smartlist_len(routers);
for (i=0;i<n;i++) {
r = smartlist_get(routers, i);
log_fn(LOG_DEBUG,"Contemplating whether router %d (%s) is a new option...",
i, r->nickname);
// log_fn(LOG_DEBUG,"Contemplating whether router %d (%s) is a new option...",
// i, r->nickname);
if (r->is_running == 0) {
log_fn(LOG_DEBUG,"Nope, the directory says %d is not running.",i);
// log_fn(LOG_DEBUG,"Nope, the directory says %d is not running.",i);
goto next_i_loop;
}
if (r->is_verified == 0) {
log_fn(LOG_DEBUG,"Nope, the directory says %d is not verified.",i);
// log_fn(LOG_DEBUG,"Nope, the directory says %d is not verified.",i);
/* XXXX009 But unverified routers *are* sometimes acceptable. */
goto next_i_loop;
}
num++;
log_fn(LOG_DEBUG,"I like %d. num_acceptable_routers now %d.",i, num);
// log_fn(LOG_DEBUG,"I like %d. num_acceptable_routers now %d.",i, num);
next_i_loop:
; /* C requires an explicit statement after the label */
}

View File

@ -725,7 +725,7 @@ router_parse_list_from_string(const char **s, routerlist_t **dest,
router->status_set_at = time(NULL);
}
smartlist_add(routers, router);
log_fn(LOG_DEBUG,"just added router #%d.",smartlist_len(routers));
// log_fn(LOG_DEBUG,"just added router #%d.",smartlist_len(routers));
}
if (good_nickname_list) {
@ -945,9 +945,9 @@ routerinfo_t *router_parse_entry_from_string(const char *s,
router->platform = tor_strdup("<unknown>");
}
log_fn(LOG_DEBUG,"or_port %d, socks_port %d, dir_port %d, bandwidthrate %u, bandwidthburst %u.",
router->or_port, router->socks_port, router->dir_port,
(unsigned) router->bandwidthrate, (unsigned) router->bandwidthburst);
// log_fn(LOG_DEBUG,"or_port %d, socks_port %d, dir_port %d, bandwidthrate %u, bandwidthburst %u.",
// router->or_port, router->socks_port, router->dir_port,
// (unsigned) router->bandwidthrate, (unsigned) router->bandwidthburst);
goto done;
return router;
@ -1052,8 +1052,8 @@ router_parse_addr_policy(directory_token_t *tok) {
newe = tor_malloc_zero(sizeof(struct addr_policy_t));
newe->string = tor_malloc(8+strlen(arg));
tor_snprintf(newe->string, 8+strlen(arg), "%s %s",
(tok->tp == K_REJECT) ? "reject" : "accept", arg);
// tor_snprintf(newe->string, 8+strlen(arg), "%s %s",
// (tok->tp == K_REJECT) ? "reject" : "accept", arg);
newe->policy_type = (tok->tp == K_REJECT) ? ADDR_POLICY_REJECT
: ADDR_POLICY_ACCEPT;
@ -1063,10 +1063,10 @@ router_parse_addr_policy(directory_token_t *tok) {
in.s_addr = htonl(newe->addr);
address = tor_strdup(inet_ntoa(in));
in.s_addr = htonl(newe->msk);
log_fn(LOG_DEBUG,"%s %s/%s:%d-%d",
newe->policy_type == ADDR_POLICY_REJECT ? "reject" : "accept",
address, inet_ntoa(in), newe->prt_min, newe->prt_max);
// in.s_addr = htonl(newe->msk);
// log_fn(LOG_DEBUG,"%s %s/%s:%d-%d",
// newe->policy_type == ADDR_POLICY_REJECT ? "reject" : "accept",
// address, inet_ntoa(in), newe->prt_min, newe->prt_max);
tor_free(address);
return newe;