mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
r13109@catbus: nickm | 2007-05-31 14:59:30 -0400
More code for voting and vote parsing (checkpointing) svn:r10423
This commit is contained in:
parent
5d4b426a33
commit
884cb0c7a1
@ -1810,20 +1810,22 @@ generate_networkstatus_opinion(int v2)
|
|||||||
"vote-status vote\n"
|
"vote-status vote\n"
|
||||||
"published %s\n"
|
"published %s\n"
|
||||||
"valid-after %s\n"
|
"valid-after %s\n"
|
||||||
|
"fresh-until %s\n"
|
||||||
"valid-until %s\n"
|
"valid-until %s\n"
|
||||||
"%s" /* versions */
|
"%s" /* versions */
|
||||||
"known-flags Authority Exit Fast Guard Stable "
|
"known-flags Authority%s Exit Fast Guard%s Running Stable "
|
||||||
"Running Valid V2Dir%s%s\n"
|
"Valid V2Dir\n"
|
||||||
"dir-source %s %s %s %s %d\n"
|
"dir-source %s %s %s %s %d %d\n"
|
||||||
"contact %s\n",
|
"contact %s\n",
|
||||||
published,
|
published,
|
||||||
published, /* XXXX020 should be valid-after*/
|
published, /* XXXX020 should be valid-after*/
|
||||||
|
published, /* XXXX020 should be fresh-until*/
|
||||||
published, /* XXXX020 should be valid-until*/
|
published, /* XXXX020 should be valid-until*/
|
||||||
version_lines,
|
version_lines,
|
||||||
naming ? " Named" : "",
|
|
||||||
listbadexits ? " BadExit" : "",
|
listbadexits ? " BadExit" : "",
|
||||||
|
naming ? " Named" : "",
|
||||||
options->Nickname, fingerprint, options->Address,
|
options->Nickname, fingerprint, options->Address,
|
||||||
ipaddr, (int)options->DirPort,
|
ipaddr, (int)options->DirPort, (int)options->ORPort,
|
||||||
contact);
|
contact);
|
||||||
outp = status + strlen(status);
|
outp = status + strlen(status);
|
||||||
endp = status + len;
|
endp = status + len;
|
||||||
|
28
src/or/or.h
28
src/or/or.h
@ -1252,7 +1252,7 @@ typedef struct local_routerstatus_t {
|
|||||||
* up? */
|
* up? */
|
||||||
#define MAX_ROUTERDESC_DOWNLOAD_FAILURES 8
|
#define MAX_ROUTERDESC_DOWNLOAD_FAILURES 8
|
||||||
|
|
||||||
/** Contents of a (v2 or later) network status object. */
|
/** Contents of a v2 (non-consensus, non-vote) network status object. */
|
||||||
typedef struct networkstatus_t {
|
typedef struct networkstatus_t {
|
||||||
/** When did we receive the network-status document? */
|
/** When did we receive the network-status document? */
|
||||||
time_t received_on;
|
time_t received_on;
|
||||||
@ -1293,6 +1293,32 @@ typedef struct networkstatus_t {
|
|||||||
* sorted by identity_digest. */
|
* sorted by identity_digest. */
|
||||||
} networkstatus_t;
|
} networkstatus_t;
|
||||||
|
|
||||||
|
/** DOCDOC */
|
||||||
|
typedef struct ns_vote_routerstatus_t {
|
||||||
|
routerstatus_t status;
|
||||||
|
uint64_t flags;
|
||||||
|
char *version;
|
||||||
|
} ns_vote_routerstatus_t;
|
||||||
|
|
||||||
|
/** DOCDOC */
|
||||||
|
typedef struct networkstatus_vote_t {
|
||||||
|
time_t published;
|
||||||
|
time_t valid_after;
|
||||||
|
time_t fresh_until;
|
||||||
|
time_t valid_until;
|
||||||
|
char *client_versions;
|
||||||
|
char *server_versions;
|
||||||
|
char **known_flags;
|
||||||
|
char identity_digest[DIGEST_LEN];
|
||||||
|
char *address;
|
||||||
|
uint32_t addr;
|
||||||
|
uint16_t dir_port;
|
||||||
|
uint16_t or_port;
|
||||||
|
struct authority_cert_t *cert;
|
||||||
|
char *contact;
|
||||||
|
smartlist_t *routerstatus_list;
|
||||||
|
} networkstatus_vote_t;
|
||||||
|
|
||||||
/** Contents of a directory of onion routers. */
|
/** Contents of a directory of onion routers. */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** Map from server identity digest to a member of routers. */
|
/** Map from server identity digest to a member of routers. */
|
||||||
|
@ -1448,15 +1448,17 @@ find_start_of_next_routerstatus(const char *s)
|
|||||||
* object in the string, and advance *<b>s</b> to just after the end of the
|
* object in the string, and advance *<b>s</b> to just after the end of the
|
||||||
* router status. Return NULL and advance *<b>s</b> on error. */
|
* router status. Return NULL and advance *<b>s</b> on error. */
|
||||||
static routerstatus_t *
|
static routerstatus_t *
|
||||||
routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens)
|
routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens,
|
||||||
|
networkstatus_vote_t *vote,
|
||||||
|
uint64_t *flags_out)
|
||||||
{
|
{
|
||||||
const char *eos;
|
const char *eos;
|
||||||
routerstatus_t *rs = NULL;
|
routerstatus_t *rs = NULL;
|
||||||
directory_token_t *tok;
|
directory_token_t *tok;
|
||||||
char timebuf[ISO_TIME_LEN+1];
|
char timebuf[ISO_TIME_LEN+1];
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
|
|
||||||
tor_assert(tokens);
|
tor_assert(tokens);
|
||||||
|
tor_assert(bool_eq(flags_out, vote));
|
||||||
|
|
||||||
eos = find_start_of_next_routerstatus(*s);
|
eos = find_start_of_next_routerstatus(*s);
|
||||||
|
|
||||||
@ -1511,7 +1513,18 @@ routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens)
|
|||||||
rs->or_port =(uint16_t) tor_parse_long(tok->args[6],10,0,65535,NULL,NULL);
|
rs->or_port =(uint16_t) tor_parse_long(tok->args[6],10,0,65535,NULL,NULL);
|
||||||
rs->dir_port = (uint16_t) tor_parse_long(tok->args[7],10,0,65535,NULL,NULL);
|
rs->dir_port = (uint16_t) tor_parse_long(tok->args[7],10,0,65535,NULL,NULL);
|
||||||
|
|
||||||
if ((tok = find_first_by_keyword(tokens, K_S))) {
|
tok = find_first_by_keyword(tokens, K_S);
|
||||||
|
if (tok && vote) {
|
||||||
|
int i, j;
|
||||||
|
for (i=0; i < tok->n_args; ++i) {
|
||||||
|
for (j=0; vote->known_flags[j]; ++j) {
|
||||||
|
if (!strcmp(tok->args[i], vote->known_flags[j])) {
|
||||||
|
*flags_out |= (1<<j);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (tok) {
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i < tok->n_args; ++i) {
|
for (i=0; i < tok->n_args; ++i) {
|
||||||
if (!strcmp(tok->args[i], "Exit"))
|
if (!strcmp(tok->args[i], "Exit"))
|
||||||
@ -1708,7 +1721,7 @@ networkstatus_parse_from_string(const char *s)
|
|||||||
smartlist_clear(tokens);
|
smartlist_clear(tokens);
|
||||||
while (!strcmpstart(s, "r ")) {
|
while (!strcmpstart(s, "r ")) {
|
||||||
routerstatus_t *rs;
|
routerstatus_t *rs;
|
||||||
if ((rs = routerstatus_parse_entry_from_string(&s, tokens)))
|
if ((rs = routerstatus_parse_entry_from_string(&s, tokens, NULL, NULL)))
|
||||||
smartlist_add(ns->entries, rs);
|
smartlist_add(ns->entries, rs);
|
||||||
}
|
}
|
||||||
smartlist_sort(ns->entries, _compare_routerstatus_entries);
|
smartlist_sort(ns->entries, _compare_routerstatus_entries);
|
||||||
|
Loading…
Reference in New Issue
Block a user