mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
use unverified routers in the desired positions
svn:r2249
This commit is contained in:
parent
590cd621f8
commit
ee23b7a470
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
12
src/or/or.h
12
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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
* <b>sl</b>.
|
||||
*/
|
||||
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;i<smartlist_len(routerlist->routers);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);
|
||||
|
Loading…
Reference in New Issue
Block a user