diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 7226488775..b3d8159577 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -1422,6 +1422,7 @@ generate_v2_networkstatus(void) ri->cache_info.identity_digest); int f_named = naming && ri->is_named; int f_valid = ri->is_verified; + int f_guard = f_fast && f_stable; /* 0.1.1.9-alpha is the first version to support fetch by descriptor * hash. */ int f_v2_dir = ri->dir_port && @@ -1450,6 +1451,7 @@ generate_v2_networkstatus(void) f_authority?" Authority":"", f_exit?" Exit":"", f_fast?" Fast":"", + f_guard?" Guard":"", f_named?" Named":"", f_stable?" Stable":"", f_running?" Running":"", diff --git a/src/or/or.h b/src/or/or.h index 1f82b90ea6..3ab5826f6f 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -844,6 +844,8 @@ typedef struct routerstatus_t { * information with v2 of the directory * protocol. (All directory caches cache v1 * directories.) */ + unsigned int is_possible_guard:1; /**< True iff this router would be a good + * choice as an entry guard. */ /** True if we, as a directory mirror, want to download the corresponding * routerinfo from the authority who gave us this routerstatus. (That is, diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 6a4bc5cbb5..72ba8f4d70 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -2941,7 +2941,7 @@ routerstatus_list_update_from_networkstatus(time_t now) */ while (1) { int n_running=0, n_named=0, n_valid=0, n_listing=0; - int n_v2_dir=0, n_fast=0, n_stable=0, n_exit=0; + int n_v2_dir=0, n_fast=0, n_stable=0, n_exit=0, n_guard=0; int n_desc_digests=0, highest_count=0; const char *the_name = NULL; local_routerstatus_t *rs_out, *rs_old; @@ -3020,6 +3020,8 @@ routerstatus_list_update_from_networkstatus(time_t now) ++n_exit; if (rs->is_fast) ++n_fast; + if (rs->is_possible_guard) + ++n_guard; if (rs->is_stable) ++n_stable; if (rs->is_v2_dir) @@ -3069,6 +3071,7 @@ routerstatus_list_update_from_networkstatus(time_t now) rs_out->status.is_running = n_running > n_recent/2; rs_out->status.is_exit = n_exit > n_statuses/2; rs_out->status.is_fast = n_fast > n_statuses/2; + rs_out->status.is_fast = n_guard > n_statuses/2; rs_out->status.is_stable = n_stable > n_statuses/2; rs_out->status.is_v2_dir = n_v2_dir > n_statuses/2; } diff --git a/src/or/routerparse.c b/src/or/routerparse.c index fef16954d5..00bc8a454a 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -1037,6 +1037,8 @@ routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens) rs->is_valid = 1; else if (!strcmp(tok->args[i], "V2Dir")) rs->is_v2_dir = 1; + else if (!strcmp(tok->args[i], "Guard")) + rs->is_possible_guard = 1; } }