diff options
author | George Tankersley <george.tankersley@gmail.com> | 2015-12-10 22:55:42 -0800 |
---|---|---|
committer | George Tankersley <george.tankersley@gmail.com> | 2016-01-06 11:22:30 -0800 |
commit | 3bc45f2628b8f9f979835503b42f6ae103dbd703 (patch) | |
tree | 03935c7abed34d55f94d753765343442dcb0cdfc /src/or | |
parent | 7660471054e2ee6568ddbbadbd9190f9ca4efb5a (diff) | |
download | tor-3bc45f2628b8f9f979835503b42f6ae103dbd703.tar.gz tor-3bc45f2628b8f9f979835503b42f6ae103dbd703.zip |
Add FallbackDir list to GETINFO config/defaults
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/src/or/config.c b/src/or/config.c index a1f8e49163..ff25a79a0b 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -938,6 +938,14 @@ static const char *default_authorities[] = { NULL }; +/** List of fallback directory authorities. The list is generated by opt-in of + * relays that meet certain stability criteria. + */ +static const char *default_fallbacks[] = { +#include "fallback_dirs.inc" + NULL +}; + /** Add the default directory authorities directly into the trusted dir list, * but only add them insofar as they share bits with <b>type</b>. * Each authority's bits are restricted to the bits shared with <b>type</b>. @@ -960,14 +968,10 @@ MOCK_IMPL(void, add_default_fallback_dir_servers,(void)) { int i; - const char *fallback[] = { -#include "fallback_dirs.inc" - NULL - }; - for (i=0; fallback[i]; i++) { - if (parse_dir_fallback_line(fallback[i], 0)<0) { + for (i=0; default_fallbacks[i]; i++) { + if (parse_dir_fallback_line(default_fallbacks[i], 0)<0) { log_err(LD_BUG, "Couldn't parse internal FallbackDir line %s", - fallback[i]); + default_fallbacks[i]); } } } @@ -7390,7 +7394,7 @@ getinfo_helper_config(control_connection_t *conn, smartlist_free(sl); } else if (!strcmp(question, "config/defaults")) { smartlist_t *sl = smartlist_new(); - int i, dirauth_lines_seen = 0; + int i, dirauth_lines_seen = 0, fallback_lines_seen = 0; for (i = 0; option_vars_[i].name; ++i) { const config_var_t *var = &option_vars_[i]; if (var->initvalue != NULL) { @@ -7401,6 +7405,13 @@ getinfo_helper_config(control_connection_t *conn, */ ++dirauth_lines_seen; } + if (strcmp(option_vars_[i].name, "FallbackDir") == 0) { + /* + * Similarly count fallback lines, so that we can decided later + * to add the defaults manually. + */ + ++fallback_lines_seen; + } char *val = esc_for_log(var->initvalue); smartlist_add_asprintf(sl, "%s %s\n",var->name,val); tor_free(val); @@ -7426,6 +7437,24 @@ getinfo_helper_config(control_connection_t *conn, } } + if (fallback_lines_seen == 0 && + get_options()->UseDefaultFallbackDirs == 1) { + /* + * We didn't see any explicitly configured fallback mirrors, + * so add the defaults to the list manually. + * + * default_fallbacks is included earlier in this file and + * is a const char ** NULL-terminated array of fallback config lines. + */ + const char **i; + + for (i = default_fallbacks; *i != NULL; ++i) { + char *val = esc_for_log(*i); + smartlist_add_asprintf(sl, "FallbackDir %s\n", val); + tor_free(val); + } + } + *answer = smartlist_join_strings(sl, "", 0, NULL); SMARTLIST_FOREACH(sl, char *, c, tor_free(c)); smartlist_free(sl); |