Keep list of dirauth flags in sync between dirvote.c and fuzz_vrs.c

Suggested by Teor on PR
This commit is contained in:
Nick Mathewson 2018-12-03 12:18:45 -05:00
parent 439ffcefd5
commit 32213fa9ad
3 changed files with 27 additions and 4 deletions

View File

@ -4372,6 +4372,23 @@ clear_status_flags_on_sybil(routerstatus_t *rs)
* forget to add it to this clause. */
}
/** Space-separated list of all the flags that we will always vote on. */
const char DIRVOTE_UNIVERSAL_FLAGS[] =
"Authority "
"Exit "
"Fast "
"Guard "
"HSDir "
"Stable "
"StaleDesc "
"V2Dir "
"Valid";
/** Space-separated list of all flags that we may or may not vote on,
* depending on our configuration. */
const char DIRVOTE_OPTIONAL_FLAGS[] =
"BadExit "
"Running";
/** Return a new networkstatus_t* containing our current opinion. (For v3
* authorities) */
networkstatus_t *
@ -4620,8 +4637,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
v3_out->known_flags = smartlist_new();
smartlist_split_string(v3_out->known_flags,
"Authority Exit Fast Guard Stable V2Dir Valid HSDir "
"StaleDesc",
DIRVOTE_UNIVERSAL_FLAGS,
0, SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
if (vote_on_reachability)
smartlist_add_strdup(v3_out->known_flags, "Running");

View File

@ -92,6 +92,9 @@
/** Maximum size of a line in a vote. */
#define MAX_BW_FILE_HEADERS_LINE_LEN 1024
extern const char DIRVOTE_UNIVERSAL_FLAGS[];
extern const char DIRVOTE_OPTIONAL_FLAGS[];
/*
* Public API. Used outside of the dirauth subsystem.
*

View File

@ -3,6 +3,7 @@
#define NS_PARSE_PRIVATE
#define NETWORKSTATUS_PRIVATE
#include "core/or/or.h"
#include "feature/dirauth/dirvote.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/dirparse/unparseable.h"
#include "lib/memarea/memarea.h"
@ -35,9 +36,12 @@ fuzz_init(void)
dummy_vote = tor_malloc_zero(sizeof(*dummy_vote));
dummy_vote->known_flags = smartlist_new();
smartlist_split_string(dummy_vote->known_flags,
"Authority BadExit Exit Fast Guard HSDir "
"NoEdConsensus Running Stable V2Dir Valid",
DIRVOTE_UNIVERSAL_FLAGS,
" ", 0, 0);
smartlist_split_string(dummy_vote->known_flags,
DIRVOTE_OPTIONAL_FLAGS,
" ", 0, 0);
smartlist_sort_strings(dummy_vote->known_flags);
return 0;
}