From ee23b7a470c6bc0f5cf08ea2ca13d541626de6b6 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Tue, 17 Aug 2004 06:27:32 +0000 Subject: [PATCH] use unverified routers in the desired positions svn:r2249 --- src/or/circuitbuild.c | 16 +++++++++------- src/or/config.c | 4 ++++ src/or/or.h | 12 ++++++------ src/or/rendservice.c | 6 ++++-- src/or/routerlist.c | 12 +++++++----- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 0e047120a1..81b88e5bbc 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -837,11 +837,11 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir) router->nickname, i); continue; /* skip routers that are known to be down */ } - if(!router->is_verified) { + if(!router->is_verified && + !(options._AllowUnverified & ALLOW_UNVERIFIED_EXIT)) { n_supported[i] = -1; log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- unverified router.", router->nickname, i); - /* XXX008 maybe one day allow unverified routers as exits */ continue; /* skip unverified routers */ } if(router_exit_policy_rejects_all(router)) { @@ -948,7 +948,8 @@ static routerinfo_t *choose_good_exit_server(uint8_t purpose, routerlist_t *dir) case CIRCUIT_PURPOSE_C_GENERAL: return choose_good_exit_server_general(dir); case CIRCUIT_PURPOSE_C_ESTABLISH_REND: - r = router_choose_random_node(options.RendNodes, options.RendExcludeNodes, NULL, 0, 1, 0); + r = router_choose_random_node(options.RendNodes, options.RendExcludeNodes, + NULL, 0, 1, options._AllowUnverified & ALLOW_UNVERIFIED_RENDEZVOUS, 0); return r; default: log_fn(LOG_WARN,"unhandled purpose %d", purpose); @@ -1103,7 +1104,8 @@ static routerinfo_t *choose_good_middle_server(cpath_build_state_t *state, tor_assert(r); smartlist_add(excluded, r); } - choice = router_choose_random_node("", options.ExcludeNodes, excluded, 0, 1, 0); + choice = router_choose_random_node("", options.ExcludeNodes, excluded, + 0, 1, options._AllowUnverified & ALLOW_UNVERIFIED_MIDDLE, 0); smartlist_free(excluded); return choice; } @@ -1134,9 +1136,9 @@ static routerinfo_t *choose_good_entry_server(cpath_build_state_t *state) smartlist_add(excluded, r); } } - choice = router_choose_random_node(options.EntryNodes, - options.ExcludeNodes, excluded, 0, 1, - options.StrictEntryNodes); + choice = router_choose_random_node(options.EntryNodes, options.ExcludeNodes, + excluded, 0, 1, options._AllowUnverified & ALLOW_UNVERIFIED_ENTRY, + options.StrictEntryNodes); smartlist_free(excluded); return choice; } diff --git a/src/or/config.c b/src/or/config.c index a4d0490df2..de529aafc4 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -825,6 +825,10 @@ int getconfig(int argc, char **argv, or_options_t *options) { options->_AllowUnverified |= ALLOW_UNVERIFIED_EXIT; else if (!strcasecmp(cp, "middle")) options->_AllowUnverified |= ALLOW_UNVERIFIED_MIDDLE; + else if (!strcasecmp(cp, "introduction")) + options->_AllowUnverified |= ALLOW_UNVERIFIED_INTRODUCTION; + else if (!strcasecmp(cp, "rendezvous")) + options->_AllowUnverified |= ALLOW_UNVERIFIED_RENDEZVOUS; else { log(LOG_WARN, "Unrecognized value '%s' in AllowUnverifiedNodes", cp); diff --git a/src/or/or.h b/src/or/or.h index a0c1a7c113..fd5b9ccbd3 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -808,10 +808,11 @@ struct circuit_t { typedef struct circuit_t circuit_t; -#define ALLOW_UNVERIFIED_ENTRY 1 -#define ALLOW_UNVERIFIED_EXIT 2 -#define ALLOW_UNVERIFIED_MIDDLE 4 - +#define ALLOW_UNVERIFIED_ENTRY 1 +#define ALLOW_UNVERIFIED_EXIT 2 +#define ALLOW_UNVERIFIED_MIDDLE 4 +#define ALLOW_UNVERIFIED_RENDEZVOUS 8 +#define ALLOW_UNVERIFIED_INTRODUCTION 16 /** Configuration options for a Tor process */ typedef struct { @@ -1392,12 +1393,11 @@ routerinfo_t *router_pick_directory_server(int requireauth, int requireothers); int all_directory_servers_down(void); struct smartlist_t; void add_nickname_list_to_smartlist(struct smartlist_t *sl, const char *list); -void router_add_running_routers_to_smartlist(struct smartlist_t *sl); int router_nickname_matches(routerinfo_t *router, const char *nickname); routerinfo_t *router_choose_random_node(char *preferred, char *excluded, struct smartlist_t *excludedsmartlist, int preferuptime, int preferbandwidth, - int strict); + int allow_unverified, int strict); routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port); routerinfo_t *router_get_by_nickname(const char *nickname); routerinfo_t *router_get_by_hexdigest(const char *hexdigest); diff --git a/src/or/rendservice.c b/src/or/rendservice.c index bb8b22d917..617e185390 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -9,6 +9,8 @@ #include "or.h" +extern or_options_t options; /* command-line and config-file options */ + static circuit_t *find_intro_circuit(routerinfo_t *router, const char *pk_digest); /** Represents the mapping from a virtual port of a rendezvous service to @@ -821,8 +823,8 @@ void rend_services_introduce(void) { /* The directory is now here. Pick three ORs as intro points. */ for (j=prev_intro_nodes; j < NUM_INTRO_POINTS; ++j) { router = router_choose_random_node(service->intro_prefer_nodes, - service->intro_exclude_nodes, - exclude_routers, 1, 0, 0); + service->intro_exclude_nodes, exclude_routers, 1, 0, + options._AllowUnverified & ALLOW_UNVERIFIED_INTRODUCTION, 0); if (!router) { log_fn(LOG_WARN, "Could only establish %d introduction points for %s", smartlist_len(service->intro_nodes), service->service_id); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index dc8b0c1054..16cd55dada 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -189,7 +189,9 @@ void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list) { /** Add every router from our routerlist that is currently running to * sl. */ -void router_add_running_routers_to_smartlist(smartlist_t *sl) { +static void +router_add_running_routers_to_smartlist(smartlist_t *sl, int allow_unverified) +{ routerinfo_t *router; int i; @@ -198,8 +200,8 @@ void router_add_running_routers_to_smartlist(smartlist_t *sl) { for(i=0;irouters);i++) { router = smartlist_get(routerlist->routers, i); - /* XXX008 for now, only choose verified routers */ - if(router->is_running && router->is_verified) { + if(router->is_running && + (allow_unverified || router->is_verified)) { if(!clique_mode()) { smartlist_add(sl, router); } else { @@ -289,7 +291,7 @@ routerlist_sl_choose_by_bandwidth(smartlist_t *sl) routerinfo_t *router_choose_random_node(char *preferred, char *excluded, smartlist_t *excludedsmartlist, int preferuptime, int preferbandwidth, - int strict) + int allow_unverified, int strict) { smartlist_t *sl, *excludednodes; routerinfo_t *choice; @@ -312,7 +314,7 @@ routerinfo_t *router_choose_random_node(char *preferred, char *excluded, smartlist_free(sl); if(!choice && !strict) { sl = smartlist_create(); - router_add_running_routers_to_smartlist(sl); + router_add_running_routers_to_smartlist(sl, allow_unverified); smartlist_subtract(sl,excludednodes); if(excludedsmartlist) smartlist_subtract(sl,excludedsmartlist);