summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-05-31 19:03:44 +0000
committerNick Mathewson <nickm@torproject.org>2007-05-31 19:03:44 +0000
commit884cb0c7a1cf949f08b5b36f9aace6d1f48d5f5f (patch)
treecb92d85f377737aac9592f1bf160c67f6368b689
parent5d4b426a334873d7b01433fdf4394a0ed6bb8807 (diff)
downloadtor-884cb0c7a1cf949f08b5b36f9aace6d1f48d5f5f.tar.gz
tor-884cb0c7a1cf949f08b5b36f9aace6d1f48d5f5f.zip
r13109@catbus: nickm | 2007-05-31 14:59:30 -0400
More code for voting and vote parsing (checkpointing) svn:r10423
-rw-r--r--src/or/dirserv.c12
-rw-r--r--src/or/or.h28
-rw-r--r--src/or/routerparse.c21
3 files changed, 51 insertions, 10 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 57799487be..86b502b4c0 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1810,20 +1810,22 @@ generate_networkstatus_opinion(int v2)
"vote-status vote\n"
"published %s\n"
"valid-after %s\n"
+ "fresh-until %s\n"
"valid-until %s\n"
"%s" /* versions */
- "known-flags Authority Exit Fast Guard Stable "
- "Running Valid V2Dir%s%s\n"
- "dir-source %s %s %s %s %d\n"
+ "known-flags Authority%s Exit Fast Guard%s Running Stable "
+ "Valid V2Dir\n"
+ "dir-source %s %s %s %s %d %d\n"
"contact %s\n",
published,
published, /* XXXX020 should be valid-after*/
+ published, /* XXXX020 should be fresh-until*/
published, /* XXXX020 should be valid-until*/
version_lines,
- naming ? " Named" : "",
listbadexits ? " BadExit" : "",
+ naming ? " Named" : "",
options->Nickname, fingerprint, options->Address,
- ipaddr, (int)options->DirPort,
+ ipaddr, (int)options->DirPort, (int)options->ORPort,
contact);
outp = status + strlen(status);
endp = status + len;
diff --git a/src/or/or.h b/src/or/or.h
index 1000297bc1..26ec35b4c5 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1252,7 +1252,7 @@ typedef struct local_routerstatus_t {
* up? */
#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 {
/** When did we receive the network-status document? */
time_t received_on;
@@ -1293,6 +1293,32 @@ typedef struct networkstatus_t {
* sorted by identity_digest. */
} 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. */
typedef struct {
/** Map from server identity digest to a member of routers. */
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index a21952c2f0..fa30d86d1c 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -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
* router status. Return NULL and advance *<b>s</b> on error. */
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;
routerstatus_t *rs = NULL;
directory_token_t *tok;
char timebuf[ISO_TIME_LEN+1];
struct in_addr in;
-
tor_assert(tokens);
+ tor_assert(bool_eq(flags_out, vote));
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->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;
for (i=0; i < tok->n_args; ++i) {
if (!strcmp(tok->args[i], "Exit"))
@@ -1708,7 +1721,7 @@ networkstatus_parse_from_string(const char *s)
smartlist_clear(tokens);
while (!strcmpstart(s, "r ")) {
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_sort(ns->entries, _compare_routerstatus_entries);