diff --git a/src/or/or.h b/src/or/or.h index 3c812109d7..51247a2037 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -766,40 +766,48 @@ typedef struct running_routers_t { smartlist_t *running_routers; } running_routers_t; -/** Contents of a network status object */ +/** Contents of a single per-router entry in a network status object. + */ typedef struct routerstatus_t { - time_t published_on; - char nickname[MAX_NICKNAME_LEN+1]; - char identity_digest[DIGEST_LEN]; - char descriptor_digest[DIGEST_LEN]; - uint32_t addr; - uint16_t or_port; - uint16_t dir_port; - unsigned int is_exit:1; - unsigned int is_stable:1; - unsigned int is_fast:1; - unsigned int is_running:1; - unsigned int is_named:1; - unsigned int is_valid:1; + time_t published_on; /**< When was this router published? */ + char nickname[MAX_NICKNAME_LEN+1]; /**DataDirectory); + if (!networkstatus_list) + networkstatus_list = smartlist_create(); + + tor_snprintf(filename,sizeof(filename),"%s/cached-status", + get_options()->DataDirectory); + entries = tor_listdir(filename); + SMARTLIST_FOREACH(entries, const char *, fn, { + tor_snprintf(filename,sizeof(filename),"%s/cached-status/%s", + get_options()->DataDirectory, fn); + s = read_file_to_str(filename, 0); + if (s) { + networkstatus_t *ns; + stat(filename, &st); + log_fn(LOG_INFO, "Loading cached network status from %s", filename); + ns = networkstatus_parse_from_string(s); + ns->received_on = st.st_mtime; + smartlist_add(networkstatus_list, ns); + } + }); + return 0; +} + /* Set *outp to a smartlist containing a list of * trusted_dir_server_t * for all known trusted dirservers. Callers * must not modify the list or its contents. diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 08a47b66e1..4697dc2144 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -1318,7 +1318,7 @@ networkstatus_parse_from_string(const char *s) log_fn(LOG_WARN, "Too few arguments to fingerprint"); goto err; } - if (base16_decode(ns->fingerprint, DIGEST_LEN, tok->args[0], + if (base16_decode(ns->identity_digest, DIGEST_LEN, tok->args[0], strlen(tok->args[0]))) { log_fn(LOG_WARN, "Couldn't decode fingerprint '%s'", tok->args[0]); goto err; @@ -1340,7 +1340,7 @@ networkstatus_parse_from_string(const char *s) log_fn(LOG_WARN, "Couldn't compute signing key digest"); goto err; } - if (memcmp(tmp_digest, ns->fingerprint, DIGEST_LEN)) { + if (memcmp(tmp_digest, ns->identity_digest, DIGEST_LEN)) { log_fn(LOG_WARN, "network-status fingerprint did not match dir-signing-key"); goto err; } @@ -1351,7 +1351,6 @@ networkstatus_parse_from_string(const char *s) } ns->client_versions = tok->args[0]; - /* XXXX NM When to check these ?? */ if (!(tok = find_first_by_keyword(tokens, K_CLIENT_VERSIONS)) || tok->n_args<1){ log_fn(LOG_WARN, "Missing client-versions"); goto err;