void update_extrainfo_downloads(time_t now);
int router_have_minimum_dir_info(void);
void router_dir_info_changed(void);
+const char *get_dir_info_status_string(void);
void router_reset_descriptor_download_failures(void);
int router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2);
int routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei,
* enough directory info to build circuits that our old answer can no longer
* be trusted. */
static int need_to_update_have_min_dir_info = 1;
+/** DOCDOC */
+static char dir_info_status[128] = "";
/** Return true iff we have enough networkstatus and router information to
* start building circuits. Right now, this means "more than half the
need_to_update_have_min_dir_info = 1;
}
+/** DOCDOC */
+const char *
+get_dir_info_status_string(void)
+{
+ return dir_info_status;
+}
+
/** Change the value of have_min_dir_info, setting it true iff we have enough
* network and router information to build circuits. Clear the value of
* need_to_update_have_min_dir_info. */
networkstatus_get_reasonably_live_consensus(now);
if (!consensus) {
+ if (!networkstatus_get_latest_consensus())
+ strlcpy(dir_info_status, "We have no network-status document.",
+ sizeof(dir_info_status));
+ else
+ strlcpy(dir_info_status, "We have no recent network-status document.",
+ sizeof(dir_info_status));
res = 0;
goto done;
}
if (should_delay_dir_fetches(get_options())) {
log_notice(LD_DIR, "no known bridge descriptors running yet; stalling");
+ strlcpy(dir_info_status, "No bridge descriptors.", sizeof(dir_info_status));
res = 0;
goto done;
}
}
}
});
- res = num_present >= num_usable/4 && num_usable > 2;
+
+ if (num_present < num_usable/4) {
+ tor_snprintf(dir_info_status, sizeof(dir_info_status),
+ "We have only %d/%d usable descriptors.", num_present, num_usable);
+ res = 0;
+ } else if (num_usable < 2) {
+ tor_snprintf(dir_info_status, sizeof(dir_info_status),
+ "Only %d usable descriptor%s known!", num_usable,
+ num_usable ? "" : "s");
+ res = 0;
+ } else {
+ res = 1;
+ }
done:
if (res && !have_min_dir_info) {
control_event_client_status(LOG_NOTICE, "NOT_ENOUGH_DIR_INFO");
}
have_min_dir_info = res;
+ need_to_update_have_min_dir_info = 0;
}
/** Reset the descriptor download failure count on all routers, so that we