Implement user-declared node families.

svn:r2534
This commit is contained in:
Nick Mathewson 2004-10-15 20:52:09 +00:00
parent f882bd92ed
commit 9d5831341e
4 changed files with 45 additions and 8 deletions

View File

@ -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.

View File

@ -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 *
@ -876,6 +879,10 @@ 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) {
@ -890,7 +897,6 @@ getconfig(int argc, char **argv, or_options_t *options)
if (rend_config_services(options) < 0) {
result = -1;
}
return result;
}

View File

@ -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);

View File

@ -248,6 +248,7 @@ 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;
@ -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>.
*/