[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Comment structs, reload a field, start making network statu...
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv19410/src/or
Modified Files:
or.h routerlist.c routerparse.c
Log Message:
Comment structs, reload a field, start making network status caches work
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.665
retrieving revision 1.666
diff -u -d -r1.665 -r1.666
--- or.h 3 Sep 2005 04:37:30 -0000 1.665
+++ or.h 4 Sep 2005 23:12:27 -0000 1.666
@@ -766,40 +766,48 @@
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]; /**<The nickname this router says it has*/
+ char identity_digest[DIGEST_LEN]; /**< Digest of the router's identity key*/
+ char descriptor_digest[DIGEST_LEN]; /**< Digest of the router's most recent
+ * descriptor */
+ uint32_t addr; /**< IPv4 address for this router */
+ uint16_t or_port; /**< OR port for this router */
+ uint16_t dir_port; /**< Directory port for this router */
+ unsigned int is_exit:1; /**< True iff this router is a good exit */
+ unsigned int is_stable:1; /**< True iff this router stays up a long time */
+ unsigned int is_fast:1; /**< True iff this router has good bandwidth */
+ unsigned int is_running:1; /**< True iff this router is up */
+ unsigned int is_named:1; /**< True iff "nickname" belongs to this router */
+ unsigned int is_valid:1; /**< True iff this router is validated */
} routerstatus_t;
-/** Contents of a network status object */
+/** Contents of a (v2 or later) network status object */
typedef struct networkstatus_t {
- time_t published_on;
+ /** When did we receive the network-status document? */
+ time_t received_on;
- char *source_address;
- uint32_t source_addr;
- uint16_t source_dirport;
+ /* These fields come from the actual network-status document.*/
+ time_t published_on; /**< Declared publication date. */
- char fingerprint[DIGEST_LEN];
- char *contact;
- crypto_pk_env_t *signing_key;
- char *client_versions;
- char *server_versions;
+ char *source_address; /**< Canonical directory server hostname */
+ uint32_t source_addr; /**< Canonical directory server IP */
+ uint16_t source_dirport; /**< Canonical directory server dirport */
- int binds_names:1;
+ char identity_digest[DIGEST_LEN]; /**< Digest of signing key */
+ char *contact; /**< How to contact directory admin? (may be NULL) */
+ crypto_pk_env_t *signing_key; /**< Key used to sign this directory */
+ char *client_versions; /**< comma-separated list of recommended client
+ * versions */
+ char *server_versions; /**< comma-separated list of recommended server
+ * versions */
- smartlist_t *entries;
+ int binds_names:1; /**< True iff this directory server binds names. */
+
+ smartlist_t *entries; /**< List of router_status_t* */
} networkstatus_t;
/** Contents of a directory of onion routers. */
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.267
retrieving revision 1.268
diff -u -d -r1.267 -r1.268
--- routerlist.c 2 Sep 2005 20:37:31 -0000 1.267
+++ routerlist.c 4 Sep 2005 23:12:27 -0000 1.268
@@ -37,11 +37,15 @@
* descriptors.)
****/
-/** Global list of all of the routers that we, as an OR or OP, know about. */
+/** Global list of all of the routers that we know about. */
static routerlist_t *routerlist = NULL;
extern int has_fetched_directory; /**< from main.c */
+/** Global list of all of the current network_status documents that we know
+ * about. */
+static smartlist_t *networkstatus_list = NULL;
+
/**
* Reload the most recent cached directory (if present).
*/
@@ -74,6 +78,36 @@
return 0;
}
+int
+router_reload_networkstatus(void)
+{
+ char filename[512];
+ struct stat st;
+ smartlist_t *entries;
+ char *s;
+ tor_assert(get_options()->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 *<b>outp</b> 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.
Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerparse.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- routerparse.c 2 Sep 2005 20:37:31 -0000 1.124
+++ routerparse.c 4 Sep 2005 23:12:27 -0000 1.125
@@ -1318,7 +1318,7 @@
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 @@
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 @@
}
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;