Make dirservers generate a separate "guard" flag to mean, "would make a good entry guard". Make clients parse it and vote on it.

svn:r5856
This commit is contained in:
Nick Mathewson 2006-01-24 00:31:16 +00:00
parent f1864dfff3
commit 9f42c9d650
4 changed files with 10 additions and 1 deletions

View File

@ -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":"",

View File

@ -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,

View File

@ -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;
}

View File

@ -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;
}
}