tolerate old 0.0.7 clients that demand a certain ip:port for a router

even though it's moved on to another one.

also reduce some log verbosity.


svn:r2288
This commit is contained in:
Roger Dingledine 2004-08-18 11:20:15 +00:00
parent d6c09c054a
commit b500104cbe
4 changed files with 20 additions and 12 deletions

View File

@ -435,6 +435,7 @@ int circuit_extend(cell_t *cell, circuit_t *circ) {
int old_format; int old_format;
char *onionskin; char *onionskin;
char *id_digest=NULL; char *id_digest=NULL;
routerinfo_t *router;
if(circ->n_conn) { if(circ->n_conn) {
log_fn(LOG_WARN,"n_conn already set. Bug/attack. Closing."); log_fn(LOG_WARN,"n_conn already set. Bug/attack. Closing.");
@ -458,6 +459,11 @@ int circuit_extend(cell_t *cell, circuit_t *circ) {
if (old_format) { if (old_format) {
n_conn = connection_exact_get_by_addr_port(circ->n_addr,circ->n_port); n_conn = connection_exact_get_by_addr_port(circ->n_addr,circ->n_port);
onionskin = cell->payload+RELAY_HEADER_SIZE+4+2; onionskin = cell->payload+RELAY_HEADER_SIZE+4+2;
if(!n_conn) { /* hunt around for it a bit before giving up */
router = router_get_by_addr_port(circ->n_addr, circ->n_port);
if(router)
n_conn = connection_get_by_identity_digest(router->identity_digest, CONN_TYPE_OR);
}
} else { } else {
onionskin = cell->payload+RELAY_HEADER_SIZE+4+2; onionskin = cell->payload+RELAY_HEADER_SIZE+4+2;
id_digest = cell->payload+RELAY_HEADER_SIZE+4+2+ONIONSKIN_CHALLENGE_LEN; id_digest = cell->payload+RELAY_HEADER_SIZE+4+2+ONIONSKIN_CHALLENGE_LEN;
@ -468,7 +474,6 @@ int circuit_extend(cell_t *cell, circuit_t *circ) {
/* Note that this will close circuits where the onion has the same /* Note that this will close circuits where the onion has the same
* router twice in a row in the path. I think that's ok. * router twice in a row in the path. I think that's ok.
*/ */
routerinfo_t *router;
struct in_addr in; struct in_addr in;
in.s_addr = htonl(circ->n_addr); in.s_addr = htonl(circ->n_addr);
log_fn(LOG_INFO,"Next router (%s:%d) not connected. Connecting.", log_fn(LOG_INFO,"Next router (%s:%d) not connected. Connecting.",
@ -803,7 +808,7 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
routerinfo_t *router; routerinfo_t *router;
preferredentries = smartlist_create(); preferredentries = smartlist_create();
add_nickname_list_to_smartlist(preferredentries,options.EntryNodes); add_nickname_list_to_smartlist(preferredentries,options.EntryNodes,1);
get_connection_array(&carray, &n_connections); get_connection_array(&carray, &n_connections);
@ -892,10 +897,10 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
n_best_support, best_support, n_pending_connections); n_best_support, best_support, n_pending_connections);
preferredexits = smartlist_create(); preferredexits = smartlist_create();
add_nickname_list_to_smartlist(preferredexits,options.ExitNodes); add_nickname_list_to_smartlist(preferredexits,options.ExitNodes,1);
excludedexits = smartlist_create(); excludedexits = smartlist_create();
add_nickname_list_to_smartlist(excludedexits,options.ExcludeNodes); add_nickname_list_to_smartlist(excludedexits,options.ExcludeNodes,0);
sl = smartlist_create(); sl = smartlist_create();
@ -1177,7 +1182,7 @@ onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t
state->desired_path_len); state->desired_path_len);
excludednodes = smartlist_create(); excludednodes = smartlist_create();
add_nickname_list_to_smartlist(excludednodes,options.ExcludeNodes); add_nickname_list_to_smartlist(excludednodes,options.ExcludeNodes,0);
if(cur_len == state->desired_path_len - 1) { /* Picking last node */ if(cur_len == state->desired_path_len - 1) { /* Picking last node */
choice = router_get_by_digest(state->chosen_exit_digest); choice = router_get_by_digest(state->chosen_exit_digest);

View File

@ -48,7 +48,7 @@ static void command_time_process_cell(cell_t *cell, connection_t *conn, int *tim
time_passed = tv_udiff(&start, &end) ; time_passed = tv_udiff(&start, &end) ;
if (time_passed > 10000) { /* more than 10ms */ if (time_passed > 10000) { /* more than 10ms */
log_fn(LOG_INFO,"That call just took %ld ms.",time_passed/1000); log_fn(LOG_DEBUG,"That call just took %ld ms.",time_passed/1000);
} }
*time += time_passed; *time += time_passed;
} }

View File

@ -1394,7 +1394,7 @@ int is_legal_nickname_or_hexdigest(const char *s);
routerinfo_t *router_pick_directory_server(int requireauth, int requireothers); routerinfo_t *router_pick_directory_server(int requireauth, int requireothers);
int all_directory_servers_down(void); int all_directory_servers_down(void);
struct smartlist_t; struct smartlist_t;
void add_nickname_list_to_smartlist(struct smartlist_t *sl, const char *list); void add_nickname_list_to_smartlist(struct smartlist_t *sl, const char *list, int warn_if_down);
routerinfo_t *routerlist_find_my_routerinfo(void); routerinfo_t *routerlist_find_my_routerinfo(void);
int router_nickname_matches(routerinfo_t *router, const char *nickname); int router_nickname_matches(routerinfo_t *router, const char *nickname);
routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl); routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl);

View File

@ -152,7 +152,9 @@ int all_directory_servers_down(void) {
* nicknames in <b>list</b> name routers in our routerlist that are * nicknames in <b>list</b> name routers in our routerlist that are
* currently running. Add the routerinfos for those routers to <b>sl</b>. * currently running. Add the routerinfos for those routers to <b>sl</b>.
*/ */
void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list) { void
add_nickname_list_to_smartlist(smartlist_t *sl, const char *list, int warn_if_down)
{
const char *start,*end; const char *start,*end;
char nick[MAX_HEX_NICKNAME_LEN+1]; char nick[MAX_HEX_NICKNAME_LEN+1];
routerinfo_t *router; routerinfo_t *router;
@ -177,7 +179,8 @@ void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list) {
if (router->is_running) if (router->is_running)
smartlist_add(sl,router); smartlist_add(sl,router);
else else
log_fn(LOG_WARN,"Nickname list includes '%s' which is known but down.",nick); log_fn(warn_if_down ? LOG_WARN : LOG_DEBUG,
"Nickname list includes '%s' which is known but down.",nick);
} else } else
log_fn(has_fetched_directory ? LOG_WARN : LOG_INFO, log_fn(has_fetched_directory ? LOG_WARN : LOG_INFO,
"Nickname list includes '%s' which isn't a known router.",nick); "Nickname list includes '%s' which isn't a known router.",nick);
@ -284,7 +287,7 @@ routerlist_sl_choose_by_bandwidth(smartlist_t *sl)
SMARTLIST_FOREACH(bandwidths, uint32_t*, p, tor_free(p)); SMARTLIST_FOREACH(bandwidths, uint32_t*, p, tor_free(p));
smartlist_free(bandwidths); smartlist_free(bandwidths);
router = smartlist_get(sl, i); router = smartlist_get(sl, i);
log_fn(LOG_INFO,"Picked %s.", router->nickname); // log_fn(LOG_INFO,"Picked %s.", router->nickname);
return router; return router;
} }
@ -304,11 +307,11 @@ routerinfo_t *router_choose_random_node(char *preferred, char *excluded,
routerinfo_t *choice; routerinfo_t *choice;
excludednodes = smartlist_create(); excludednodes = smartlist_create();
add_nickname_list_to_smartlist(excludednodes,excluded); add_nickname_list_to_smartlist(excludednodes,excluded,0);
/* try the preferred nodes first */ /* try the preferred nodes first */
sl = smartlist_create(); sl = smartlist_create();
add_nickname_list_to_smartlist(sl,preferred); add_nickname_list_to_smartlist(sl,preferred,1);
smartlist_subtract(sl,excludednodes); smartlist_subtract(sl,excludednodes);
if(excludedsmartlist) if(excludedsmartlist)
smartlist_subtract(sl,excludedsmartlist); smartlist_subtract(sl,excludedsmartlist);