12 #define VOTEFLAGS_PRIVATE
44 #define UPTIME_TO_GUARANTEE_STABLE (3600*24*30)
47 #define MTBF_TO_GUARANTEE_STABLE (60*60*24*5)
52 #define TIME_KNOWN_TO_GUARANTEE_FAMILIAR (8*24*60*60)
55 #define WFU_TO_GUARANTEE_GUARD (0.98)
88 if (now < router->cache_info.published_on)
102 int need_uptime,
int need_capacity)
150 if (dirauth_get_options()->TestingMinExitFlagThreshold > 0) {
174 const node_t *node, time_t now)
187 dirauth_get_options()->MinUptimeHidServDirectoryV2 * 1.1)
196 uptime >= dirauth_get_options()->MinUptimeHidServDirectoryV2 &&
202 #define ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB 4
211 const digestmap_t *omit_as_sybil,
226 !digestmap_get(omit_as_sybil, node->
identity) &&
228 (have_mbw || !require_mbw);
241 int n_active, n_active_nonexit, n_familiar;
242 uint32_t *uptimes, *bandwidths_kb, *bandwidths_excluding_exits_kb;
244 double *mtbfs, *wfus;
246 time_t now = time(NULL);
269 n_active = n_active_nonexit = 0;
271 uptimes = tor_calloc(smartlist_len(nodelist),
sizeof(uint32_t));
273 bandwidths_kb = tor_calloc(smartlist_len(nodelist),
sizeof(uint32_t));
275 bandwidths_excluding_exits_kb =
276 tor_calloc(smartlist_len(nodelist),
sizeof(uint32_t));
278 mtbfs = tor_calloc(smartlist_len(nodelist),
sizeof(
double));
280 tks = tor_calloc(smartlist_len(nodelist),
sizeof(
long));
282 wfus = tor_calloc(smartlist_len(nodelist),
sizeof(
double));
299 const char *
id = node->identity;
305 uptimes[n_active] = (uint32_t)
real_uptime(ri, now);
309 if (!node->is_exit || node->is_bad_exit) {
310 bandwidths_excluding_exits_kb[n_active_nonexit] = bw_kb;
315 } SMARTLIST_FOREACH_END(node);
329 third_quartile_uint32(bandwidths_kb, n_active);
330 guard_tk = find_nth_long(tks, n_active, n_active/8);
338 #define ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG 4
339 int32_t min_fast_kb, max_fast_kb, min_fast, max_fast;
341 ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG,
342 ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG,
348 INT32_MAX, min_fast, INT32_MAX);
349 min_fast_kb = min_fast / 1000;
350 max_fast_kb = max_fast / 1000;
371 omit_as_sybil, require_mbw)) {
379 } SMARTLIST_FOREACH_END(node);
381 guard_wfu = median_double(wfus, n_familiar);
387 if (n_active_nonexit) {
389 find_nth_uint32(bandwidths_excluding_exits_kb,
390 n_active_nonexit, n_active_nonexit*3/4);
394 "Cutoffs: For Stable, %lu sec uptime, %lu sec MTBF. "
395 "For Fast: %lu kilobytes/sec. "
396 "For Guard: WFU %.03f%%, time-known %lu sec, "
397 "and bandwidth %lu or %lu kilobytes/sec. "
398 "We%s have enough stability data.",
411 tor_free(bandwidths_excluding_exits_kb);
423 dirserv_compute_bridge_flag_thresholds(
void)
425 digestmap_t *omit_as_sybil = digestmap_new();
427 digestmap_free(omit_as_sybil, NULL);
436 const int measured_threshold =
438 const int enough_measured_bw =
442 "stable-uptime=%lu stable-mtbf=%lu "
444 "guard-wfu=%.03f%% guard-tk=%lu "
445 "guard-bw-inc-exits=%lu guard-bw-exc-exits=%lu "
446 "enough-mtbf=%d ignoring-advertised-bws=%d",
455 enough_measured_bw ? 1 : 0);
462 running_long_enough_to_decide_unreachable(
void)
472 #define REACHABLE_TIMEOUT (45*60)
477 #define HIBERNATION_PUBLICATION_SKEW (60*60)
523 if (!answer && running_long_enough_to_decide_unreachable()) {
585 ((bw_opt && routerbw_kb >= bw_opt / 1000) ||
602 (ri->cache_info.
published_on + DESC_IS_STALE_INTERVAL) < now;
604 if (! should_publish_node_ipv6(node, ri, now)) {
630 }
else if (options->TestingDirAuthVoteExitIsStrict) {
637 }
else if (options->TestingDirAuthVoteGuardIsStrict) {
644 }
else if (options->TestingDirAuthVoteHSDirIsStrict) {
663 } SMARTLIST_FOREACH_END(ri);
void tor_addr_make_null(tor_addr_t *a, sa_family_t family)
int tor_addr_is_null(const tor_addr_t *addr)
uint32_t dirserv_get_credible_bandwidth_kb(const routerinfo_t *ri)
int dirserv_get_last_n_measured_bws(void)
int dirserv_has_measured_bw(const char *node_id)
Header file for bwauth.c.
const or_options_t * get_options(void)
Header file for config.c.
Structure dirauth_options_t to hold directory authority options.
Header for dirauth_sys.c.
Header file for dirlist.c.
int we_are_hibernating(void)
Header file for hibernate.c.
time_t time_of_process_start
Header file for mainloop.c.
int32_t networkstatus_get_param(const networkstatus_t *ns, const char *param_name, int32_t default_val, int32_t min_val, int32_t max_val)
void set_routerstatus_from_routerinfo(routerstatus_t *rs, const node_t *node, const routerinfo_t *ri)
Header file for networkstatus.c.
Node information structure.
node_t * node_get_mutable_by_id(const char *identity_digest)
const smartlist_t * nodelist_get_list(void)
void nodelist_assert_ok(void)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
#define ROUTER_MAX_AGE_TO_PUBLISH
int exit_policy_is_general_exit(smartlist_t *policy)
Header file for policies.c.
int tor_asprintf(char **strp, const char *fmt,...)
Header file for reachability.c.
#define REACHABILITY_TEST_CYCLE_PERIOD
double rep_hist_get_stability(const char *id, time_t when)
double rep_hist_get_weighted_fractional_uptime(const char *id, time_t when)
long rep_hist_get_uptime(const char *id, time_t when)
long rep_hist_get_weighted_time_known(const char *id, time_t when)
void rep_hist_note_router_unreachable(const char *id, time_t when)
int rep_hist_have_measured_enough_stability(void)
Header file for rephist.c.
int router_is_me(const routerinfo_t *router)
Header file for router.c.
Router descriptor structure.
#define ROUTER_PURPOSE_BRIDGE
int router_exit_policy_rejects_all(const routerinfo_t *router)
routerlist_t * router_get_routerlist(void)
Header file for routerlist.c.
Router descriptor list structure.
int routerset_contains_routerstatus(const routerset_t *set, const routerstatus_t *rs, country_t country)
Header file for routerset.c.
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
MEMUNIT AuthDirFastGuarantee
BOOL AuthDirTestReachability
MEMUNIT AuthDirGuardBWGuarantee
ROUTERSET TestingDirAuthVoteGuard
BOOL AuthDirHasIPv6Connectivity
INTERVAL TestingAuthDirTimeToLearnReachability
MEMUNIT TestingMinExitFlagThreshold
ROUTERSET TestingDirAuthVoteExit
ROUTERSET TestingDirAuthVoteHSDir
MEMUNIT TestingMinFastFlagThreshold
INT MinMeasuredBWsForAuthToIgnoreAdvertised
char identity[DIGEST_LEN]
int BridgeAuthoritativeDir
smartlist_t * exit_policy
unsigned int wants_to_be_hs_dir
unsigned int is_hibernating
unsigned int supports_tunnelled_dir_requests
uint32_t bandwidthcapacity
unsigned int is_staledesc
unsigned int is_possible_guard
char identity_digest[DIGEST_LEN]
Routerstatus (vote entry) structure.
#define MTBF_TO_GUARANTEE_STABLE
STATIC void dirserv_set_routerstatus_testing(routerstatus_t *rs)
#define HIBERNATION_PUBLICATION_SKEW
#define ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB
void dirauth_set_routerstatus_from_routerinfo(routerstatus_t *rs, node_t *node, const routerinfo_t *ri, time_t now, int listbadexits)
static int router_counts_toward_thresholds(const node_t *node, time_t now, const digestmap_t *omit_as_sybil, int require_mbw)
static uint32_t stable_uptime
static long real_uptime(const routerinfo_t *router, time_t now)
#define REACHABLE_TIMEOUT
#define WFU_TO_GUARANTEE_GUARD
static double stable_mtbf
char * dirserv_get_flag_thresholds_line(void)
void dirserv_compute_performance_thresholds(digestmap_t *omit_as_sybil)
static int dirserv_thinks_router_is_hs_dir(const routerinfo_t *router, const node_t *node, time_t now)
static int dirserv_thinks_router_is_unreliable(time_t now, const routerinfo_t *router, int need_uptime, int need_capacity)
#define UPTIME_TO_GUARANTEE_STABLE
static int router_is_active(const routerinfo_t *ri, const node_t *node, time_t now)
static uint32_t fast_bandwidth_kb
#define TIME_KNOWN_TO_GUARANTEE_FAMILIAR
void dirserv_set_router_is_running(routerinfo_t *router, time_t now)
void dirserv_set_bridges_running(time_t now)
static int enough_mtbf_info
static uint32_t guard_bandwidth_excluding_exits_kb
static uint32_t guard_bandwidth_including_exits_kb
Header file for voteflags.c.