[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r10423: More code for voting and vote parsing (checkpointing) (in tor/trunk: . src/or)
Author: nickm
Date: 2007-05-31 15:03:44 -0400 (Thu, 31 May 2007)
New Revision: 10423
Modified:
tor/trunk/
tor/trunk/src/or/dirserv.c
tor/trunk/src/or/or.h
tor/trunk/src/or/routerparse.c
Log:
r13109@catbus: nickm | 2007-05-31 14:59:30 -0400
More code for voting and vote parsing (checkpointing)
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r13109] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c 2007-05-31 18:48:31 UTC (rev 10422)
+++ tor/trunk/src/or/dirserv.c 2007-05-31 19:03:44 UTC (rev 10423)
@@ -1810,20 +1810,22 @@
"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,
+ listbadexits ? " BadExit" : "",
naming ? " Named" : "",
- listbadexits ? " BadExit" : "",
options->Nickname, fingerprint, options->Address,
- ipaddr, (int)options->DirPort,
+ ipaddr, (int)options->DirPort, (int)options->ORPort,
contact);
outp = status + strlen(status);
endp = status + len;
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2007-05-31 18:48:31 UTC (rev 10422)
+++ tor/trunk/src/or/or.h 2007-05-31 19:03:44 UTC (rev 10423)
@@ -1252,7 +1252,7 @@
* 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 @@
* 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. */
Modified: tor/trunk/src/or/routerparse.c
===================================================================
--- tor/trunk/src/or/routerparse.c 2007-05-31 18:48:31 UTC (rev 10422)
+++ tor/trunk/src/or/routerparse.c 2007-05-31 19:03:44 UTC (rev 10423)
@@ -1448,15 +1448,17 @@
* 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 @@
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 @@
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);