12#define VOTEFLAGS_PRIVATE
70 if (now < router->cache_info.published_on)
84 int need_uptime,
int need_capacity)
96 uptime < dirauth_get_options()->AuthDirVoteStableGuaranteeMinUptime)
102 mtbf < dirauth_get_options()->AuthDirVoteStableGuaranteeMTBF)
141 const node_t *node, time_t now)
154 dirauth_get_options()->MinUptimeHidServDirectoryV2 * 1.1)
163 uptime >= dirauth_get_options()->MinUptimeHidServDirectoryV2 &&
169#define ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB 4
178 const digestmap_t *omit_as_sybil,
193 !digestmap_get(omit_as_sybil, node->
identity) &&
195 (have_mbw || !require_mbw);
208 int n_active, n_active_nonexit, n_familiar;
209 uint32_t *uptimes, *bandwidths_kb, *bandwidths_excluding_exits_kb;
211 double *mtbfs, *wfus;
213 time_t now = time(NULL);
236 n_active = n_active_nonexit = 0;
238 uptimes = tor_calloc(smartlist_len(nodelist),
sizeof(uint32_t));
240 bandwidths_kb = tor_calloc(smartlist_len(nodelist),
sizeof(uint32_t));
242 bandwidths_excluding_exits_kb =
243 tor_calloc(smartlist_len(nodelist),
sizeof(uint32_t));
245 mtbfs = tor_calloc(smartlist_len(nodelist),
sizeof(
double));
247 tks = tor_calloc(smartlist_len(nodelist),
sizeof(
long));
249 wfus = tor_calloc(smartlist_len(nodelist),
sizeof(
double));
266 const char *
id = node->identity;
272 uptimes[n_active] = (uint32_t)
real_uptime(ri, now);
276 if (!node->is_exit || node->is_bad_exit) {
277 bandwidths_excluding_exits_kb[n_active_nonexit] = bw_kb;
282 } SMARTLIST_FOREACH_END(node);
295 int nth = (int)(n_active *
298 find_nth_uint32(bandwidths_kb, n_active, nth);
299 guard_tk = find_nth_long(tks, n_active, n_active/8);
307#define ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG 4
308 int32_t min_fast_kb, max_fast_kb, min_fast, max_fast;
310 ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG,
311 ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG,
317 INT32_MAX, min_fast, INT32_MAX);
318 min_fast_kb = min_fast / 1000;
319 max_fast_kb = max_fast / 1000;
340 omit_as_sybil, require_mbw)) {
348 } SMARTLIST_FOREACH_END(node);
350 guard_wfu = median_double(wfus, n_familiar);
356 if (n_active_nonexit) {
357 int nth = (int)(n_active_nonexit *
360 find_nth_uint32(bandwidths_excluding_exits_kb, n_active_nonexit, nth);
364 "Cutoffs: For Stable, %lu sec uptime, %lu sec MTBF. "
365 "For Fast: %lu kilobytes/sec. "
366 "For Guard: WFU %.03f%%, time-known %lu sec, "
367 "and bandwidth %lu or %lu kilobytes/sec. "
368 "We%s have enough stability data.",
381 tor_free(bandwidths_excluding_exits_kb);
393dirserv_compute_bridge_flag_thresholds(
void)
395 digestmap_t *omit_as_sybil = digestmap_new();
397 digestmap_free(omit_as_sybil, NULL);
406 const int measured_threshold =
408 const int enough_measured_bw =
412 "stable-uptime=%lu stable-mtbf=%lu "
414 "guard-wfu=%.03f%% guard-tk=%lu "
415 "guard-bw-inc-exits=%lu guard-bw-exc-exits=%lu "
416 "enough-mtbf=%d ignoring-advertised-bws=%d",
425 enough_measured_bw ? 1 : 0);
461#define REACHABLE_TIMEOUT (45*60)
466#define HIBERNATION_PUBLICATION_SKEW (60*60)
590 ((bw_opt && routerbw_kb >= bw_opt / 1000) ||
615 (ri->cache_info.
published_on + DESC_IS_STALE_INTERVAL) < now;
617 if (! should_publish_node_ipv6(node, ri, now)) {
645 }
else if (options->TestingDirAuthVoteExitIsStrict) {
652 }
else if (options->TestingDirAuthVoteGuardIsStrict) {
659 }
else if (options->TestingDirAuthVoteHSDirIsStrict) {
678 } 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.
const smartlist_t * nodelist_get_list(void)
node_t * node_get_mutable_by_id(const char *identity_digest)
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
DOUBLE AuthDirVoteGuardBwThresholdFraction
ROUTERSET AuthDirVoteGuard
BOOL AuthDirHasIPv6Connectivity
INTERVAL TestingAuthDirTimeToLearnReachability
MEMUNIT TestingMinExitFlagThreshold
ROUTERSET TestingDirAuthVoteExit
INTERVAL AuthDirVoteGuardGuaranteeTimeKnown
ROUTERSET TestingDirAuthVoteHSDir
MEMUNIT TestingMinFastFlagThreshold
INT MinMeasuredBWsForAuthToIgnoreAdvertised
DOUBLE AuthDirVoteGuardGuaranteeWFU
char identity[DIGEST_LEN]
unsigned int is_middle_only
int BridgeAuthoritativeDir
smartlist_t * exit_policy
unsigned int wants_to_be_hs_dir
unsigned int is_hibernating
unsigned int supports_tunnelled_dir_requests
unsigned int is_staledesc
unsigned int is_possible_guard
unsigned int is_middle_only
char identity_digest[DIGEST_LEN]
Routerstatus (vote entry) structure.
STATIC void dirserv_set_routerstatus_testing(routerstatus_t *rs)
int running_long_enough_to_decide_unreachable(void)
#define HIBERNATION_PUBLICATION_SKEW
#define ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB
static void dirserv_set_routerstatus_flags(routerstatus_t *rs)
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
static double stable_mtbf
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)
static int router_is_active(const routerinfo_t *ri, const node_t *node, time_t now)
void dirauth_set_routerstatus_from_routerinfo(routerstatus_t *rs, node_t *node, const routerinfo_t *ri, time_t now, int listbadexits, int listmiddleonly)
static uint32_t fast_bandwidth_kb
void dirserv_set_router_is_running(routerinfo_t *router, time_t now)
void dirserv_set_bridges_running(time_t now)
char * dirserv_get_flag_thresholds_line(void)
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.