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