Commit 9d583134 authored by Nick Mathewson's avatar Nick Mathewson 🎨
Browse files

Implement user-declared node families.


svn:r2534
parent f882bd92
......@@ -22,7 +22,7 @@ N - Handle rendezvousing with unverified nodes.
o node 'groups' that are known to be in the same zone of control.
o Nodes can list their coadministrated nodes.
o If A lists B, it only counts if B also lists A
N - Users can list other coadministrated nodes if they like.
o Users can list other coadministrated nodes if they like.
o Never choose two coadministrated nodes in the same circuit.
R - figure out enclaves, e.g. so we know what to recommend that people
do, and so running a tor server on your website is helpful.
......
......@@ -245,6 +245,7 @@ config_assign(or_options_t *options, struct config_line_t *list)
config_compare(list, "FascistFirewall",CONFIG_TYPE_BOOL, &options->FascistFirewall) ||
config_compare(list, "FirewallPorts",CONFIG_TYPE_CSV, &options->FirewallPorts) ||
config_compare(list, "MyFamily", CONFIG_TYPE_STRING, &options->MyFamily) ||
config_compare(list, "NodeFamily", CONFIG_TYPE_LINELIST, &options->NodeFamilies) ||
config_compare(list, "Group", CONFIG_TYPE_STRING, &options->Group) ||
......@@ -477,6 +478,7 @@ free_options(or_options_t *options)
config_free_lines(options->SocksPolicy);
config_free_lines(options->DirServers);
config_free_lines(options->RecommendedVersions);
config_free_lines(options->NodeFamilies);
if (options->FirewallPorts) {
SMARTLIST_FOREACH(options->FirewallPorts, char *, cp, tor_free(cp));
smartlist_free(options->FirewallPorts);
......@@ -519,6 +521,7 @@ init_options(or_options_t *options)
options->FirewallPorts = NULL;
options->DirServers = NULL;
options->MyFamily = NULL;
options->NodeFamilies = NULL;
}
static char *
......@@ -560,7 +563,7 @@ get_default_conf_file(void)
* nicknames, or NULL. Return 0 on success. Warn and return -1 on failure.
*/
static int check_nickname_list(const char *lst, const char *name)
{
{
int r = 0;
smartlist_t *sl;
......@@ -576,7 +579,7 @@ static int check_nickname_list(const char *lst, const char *name)
}
});
SMARTLIST_FOREACH(sl, char *, s, tor_free(s));
smartlist_free(sl);
smartlist_free(sl);
return r;
}
......@@ -876,7 +879,11 @@ getconfig(int argc, char **argv, or_options_t *options)
return -1;
if (check_nickname_list(options->MyFamily, "MyFamily"))
return -1;
for (cl = options->NodeFamilies; cl; cl = cl->next) {
if (check_nickname_list(cl->value, "NodeFamily"))
return -1;
}
clear_trusted_dir_servers();
if (!options->DirServers) {
add_default_trusted_dirservers();
......@@ -890,7 +897,6 @@ getconfig(int argc, char **argv, or_options_t *options)
if (rend_config_services(options) < 0) {
result = -1;
}
return result;
}
......
......@@ -859,7 +859,7 @@ typedef struct {
/** Local address to bind outbound sockets */
char *OutboundBindAddress;
struct config_line_t *RecommendedVersions;
/**< Directory server only: which versions of
/**< Directory server only: which versions of
* Tor should we tell users to run? */
char *User; /**< Name of user to run Tor as. */
char *Group; /**< Name of group to run Tor as. */
......@@ -904,6 +904,8 @@ typedef struct {
struct config_line_t *DirServers; /**< List of configuration lines
* for directory servers. */
char *MyFamily; /**< Declared family for this OR. */
struct config_line_t *NodeFamilies; /**< List of config lines for
* node families */
} or_options_t;
/* XXX are these good enough defaults? */
......@@ -1420,6 +1422,7 @@ int all_trusted_directory_servers_down(void);
struct smartlist_t;
void routerlist_add_family(struct smartlist_t *sl, routerinfo_t *router);
void add_nickname_list_to_smartlist(struct smartlist_t *sl, const char *list, int warn_if_down);
int router_nickname_is_in_list(routerinfo_t *router, const char *list);
routerinfo_t *routerlist_find_my_routerinfo(void);
int router_nickname_matches(routerinfo_t *router, const char *nickname);
int router_is_unreliable_router(routerinfo_t *router, int need_uptime, int need_bw);
......
......@@ -248,10 +248,11 @@ int all_trusted_directory_servers_down(void) {
*/
void routerlist_add_family(smartlist_t *sl, routerinfo_t *router) {
routerinfo_t *r;
struct config_line_t *cl;
if (!router->declared_family)
return;
/* Add every r such that router declares familyness with r, and r
* declares familyhood with router. */
SMARTLIST_FOREACH(router->declared_family, const char *, n,
......@@ -266,6 +267,13 @@ void routerlist_add_family(smartlist_t *sl, routerinfo_t *router) {
smartlist_add(sl, r);
});
});
for (cl = options.NodeFamilies; cl; cl = cl->next) {
if (router_nickname_is_in_list(router, cl->value)) {
add_nickname_list_to_smartlist(sl, cl->value, 0);
}
}
}
/** Given a comma-and-whitespace separated list of nicknames, see which
......@@ -306,6 +314,26 @@ add_nickname_list_to_smartlist(smartlist_t *sl, const char *list, int warn_if_do
smartlist_free(nickname_list);
}
/** Return 1 iff any member of the comma-separated list <b>list</b> is an
* acceptable nickname or hexdigest for <b>router</b>. Else return 0.
*/
int
router_nickname_is_in_list(routerinfo_t *router, const char *list)
{
smartlist_t *nickname_list;
int v = 0;
tor_assert(router);
tor_assert(list);
nickname_list = smartlist_create();
smartlist_split_string(nickname_list, list, ",",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
SMARTLIST_FOREACH(nickname_list, char *, cp,
if (router_nickname_matches(router, cp)) {v=1;break;});
return v;
}
/** Add every router from our routerlist that is currently running to
* <b>sl</b>.
*/
......@@ -405,7 +433,7 @@ routerlist_sl_choose_by_bandwidth(smartlist_t *sl)
// log_fn(LOG_INFO,"Recording bw %d for node %s.", this_bw, router->nickname);
}
if(!total_bw)
return NULL;
return NULL;
rand_bw = crypto_pseudo_rand_int(total_bw);
// log_fn(LOG_INFO,"Total bw %d. Randomly chose %d.", total_bw, rand_bw);
tmp = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment