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)
132 if (dirauth_get_options()->TestingMinExitFlagThreshold > 0) {
156 const node_t *node, time_t now)
169 dirauth_get_options()->MinUptimeHidServDirectoryV2 * 1.1)
178 uptime >= dirauth_get_options()->MinUptimeHidServDirectoryV2 &&
184 #define ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB 4
193 const digestmap_t *omit_as_sybil,
208 !digestmap_get(omit_as_sybil, node->
identity) &&
210 (have_mbw || !require_mbw);
223 int n_active, n_active_nonexit, n_familiar;
224 uint32_t *uptimes, *bandwidths_kb, *bandwidths_excluding_exits_kb;
226 double *mtbfs, *wfus;
228 time_t now = time(NULL);
251 n_active = n_active_nonexit = 0;
253 uptimes = tor_calloc(smartlist_len(nodelist),
sizeof(uint32_t));
255 bandwidths_kb = tor_calloc(smartlist_len(nodelist),
sizeof(uint32_t));
257 bandwidths_excluding_exits_kb =
258 tor_calloc(smartlist_len(nodelist),
sizeof(uint32_t));
260 mtbfs = tor_calloc(smartlist_len(nodelist),
sizeof(
double));
262 tks = tor_calloc(smartlist_len(nodelist),
sizeof(
long));
264 wfus = tor_calloc(smartlist_len(nodelist),
sizeof(
double));
281 const char *
id = node->identity;
287 uptimes[n_active] = (uint32_t)
real_uptime(ri, now);
291 if (!node->is_exit || node->is_bad_exit) {
292 bandwidths_excluding_exits_kb[n_active_nonexit] = bw_kb;
297 } SMARTLIST_FOREACH_END(node);
310 int nth = (int)(n_active *
313 find_nth_uint32(bandwidths_kb, n_active, nth);
314 guard_tk = find_nth_long(tks, n_active, n_active/8);
322 #define ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG 4
323 int32_t min_fast_kb, max_fast_kb, min_fast, max_fast;
325 ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG,
326 ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG,
332 INT32_MAX, min_fast, INT32_MAX);
333 min_fast_kb = min_fast / 1000;
334 max_fast_kb = max_fast / 1000;
355 omit_as_sybil, require_mbw)) {
363 } SMARTLIST_FOREACH_END(node);
365 guard_wfu = median_double(wfus, n_familiar);
371 if (n_active_nonexit) {
372 int nth = (int)(n_active_nonexit *
375 find_nth_uint32(bandwidths_excluding_exits_kb, n_active_nonexit, nth);
379 "Cutoffs: For Stable, %lu sec uptime, %lu sec MTBF. "
380 "For Fast: %lu kilobytes/sec. "
381 "For Guard: WFU %.03f%%, time-known %lu sec, "
382 "and bandwidth %lu or %lu kilobytes/sec. "
383 "We%s have enough stability data.",
396 tor_free(bandwidths_excluding_exits_kb);
408 dirserv_compute_bridge_flag_thresholds(
void)
410 digestmap_t *omit_as_sybil = digestmap_new();
412 digestmap_free(omit_as_sybil, NULL);
421 const int measured_threshold =
423 const int enough_measured_bw =
427 "stable-uptime=%lu stable-mtbf=%lu "
429 "guard-wfu=%.03f%% guard-tk=%lu "
430 "guard-bw-inc-exits=%lu guard-bw-exc-exits=%lu "
431 "enough-mtbf=%d ignoring-advertised-bws=%d",
440 enough_measured_bw ? 1 : 0);
476 #define REACHABLE_TIMEOUT (45*60)
481 #define HIBERNATION_PUBLICATION_SKEW (60*60)
605 ((bw_opt && routerbw_kb >= bw_opt / 1000) ||
630 (ri->cache_info.
published_on + DESC_IS_STALE_INTERVAL) < now;
632 if (! should_publish_node_ipv6(node, ri, now)) {
660 }
else if (options->TestingDirAuthVoteExitIsStrict) {
667 }
else if (options->TestingDirAuthVoteGuardIsStrict) {
674 }
else if (options->TestingDirAuthVoteHSDirIsStrict) {
693 } 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
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
uint32_t bandwidthcapacity
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
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)
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)
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.