aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2008-09-14 04:07:29 +0000
committerRoger Dingledine <arma@torproject.org>2008-09-14 04:07:29 +0000
commitdbb481c169e8dd5ea9d7ee62bd22df0a511d442f (patch)
tree07291e447f5cc1917d711333e3b3f2a65a5e8325
parent4045ef72f5db967033bd14217eed4bfea4ea9453 (diff)
downloadtor-dbb481c169e8dd5ea9d7ee62bd22df0a511d442f.tar
tor-dbb481c169e8dd5ea9d7ee62bd22df0a511d442f.tar.gz
Serve the latest v3 networkstatus consensus via the control
port. Use "getinfo dir/status-vote/current/consensus" to fetch it. svn:r16907
-rw-r--r--ChangeLog4
-rw-r--r--doc/spec/control-spec.txt1
-rw-r--r--src/or/control.c20
-rw-r--r--src/or/directory.c2
-rw-r--r--src/or/dirserv.c2
5 files changed, 23 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 41822f0d5..ed0e3e425 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,7 +33,9 @@ Changes in version 0.2.1.6-alpha - 2008-09-xx
- Use a lockfile to make sure that two Tor processes are not
simultaneously running with the same datadir.
- Directory mirrors store and serve v2 hidden service descriptors by
- default (new default value for HidServDirectoryV2 is 1).
+ default (i.e. new default value for HidServDirectoryV2 is 1).
+ - Serve the latest v3 networkstatus consensus via the control
+ port. Use "getinfo dir/status-vote/current/consensus" to fetch it.
o Code simplifications and refactoring:
- Revise the connection_new functions so that a more typesafe variant
diff --git a/doc/spec/control-spec.txt b/doc/spec/control-spec.txt
index ceb671e16..de5cf7d70 100644
--- a/doc/spec/control-spec.txt
+++ b/doc/spec/control-spec.txt
@@ -531,6 +531,7 @@ $Id$
"next-circuit/IP:port"
XXX todo.
+ "dir/status-vote/current/consensus" [added in Tor 0.2.1.6-alpha]
"dir/status/authority"
"dir/status/fp/<F>"
"dir/status/fp/<F1>+<F2>+<F3>"
diff --git a/src/or/control.c b/src/or/control.c
index ac31f5d94..93a946405 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1401,7 +1401,7 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
* <b>ei</b> into the resulting string. The thing you get back won't
* necessarily have a valid signature.
*
- * New code should never use this; it's for backward compatibiliy.
+ * New code should never use this; it's for backward compatibility.
*
* NOTE: <b>ri_body</b> is as returned by signed_descriptor_get_body: it might
* not be NUL-terminated. */
@@ -1572,7 +1572,18 @@ getinfo_helper_dir(control_connection_t *control_conn,
SMARTLIST_FOREACH(status_list, char *, s, tor_free(s));
smartlist_free(status_list);
}
- } else if (!strcmp(question, "network-status")) {
+ } else if (!strcmp(question, "dir/status-vote/current/consensus")) { /* v3 */
+ if (directory_caches_dir_info(get_options())) {
+ const cached_dir_t *consensus = dirserv_get_consensus();
+ if (consensus)
+ *answer = tor_strdup(consensus->dir);
+ }
+ if (!*answer) { /* try loading it from disk */
+ char *filename = get_datadir_fname("cached-consensus");
+ *answer = read_file_to_str(filename, RFTS_IGNORE_MISSING, NULL);
+ tor_free(filename);
+ }
+ } else if (!strcmp(question, "network-status")) { /* v1 */
routerlist_t *routerlist = router_get_routerlist();
int verbose = control_conn->use_long_names;
if (!routerlist || !routerlist->routers ||
@@ -1920,7 +1931,10 @@ static const getinfo_item_t getinfo_items[] = {
ITEM("dir-usage", misc, "Breakdown of bytes transferred over DirPort."),
PREFIX("desc-annotations/id/", dir, "Router annotations by hexdigest."),
PREFIX("dir/server/", dir,"Router descriptors as retrieved from a DirPort."),
- PREFIX("dir/status/", dir,"Networkstatus docs as retrieved from a DirPort."),
+ PREFIX("dir/status/", dir,
+ "v2 networkstatus docs as retrieved from a DirPort."),
+ ITEM("dir/status-vote/current/consensus", dir,
+ "v3 Networkstatus consensus as retrieved from a DirPort."),
PREFIX("exit-policy/default", policies,
"The default value appended to the configured exit policy."),
PREFIX("ip-to-country/", geoip, "Perform a GEOIP lookup"),
diff --git a/src/or/directory.c b/src/or/directory.c
index 3c2c05da2..f494fe283 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2408,7 +2408,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
url_len -= 2;
}
- if (!strcmp(url,"/tor/") || !strcmp(url,"/tor/dir")) { /* dir fetch */
+ if (!strcmp(url,"/tor/") || !strcmp(url,"/tor/dir")) { /* v1 dir fetch */
cached_dir_t *d = dirserv_get_directory();
if (!d) {
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 9d718baa0..b7080aa78 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1300,7 +1300,7 @@ _free_cached_dir(void *_d)
cached_dir_decref(d);
}
-/** If we have no cached directory, or it is older than <b>published</b>,
+/** If we have no cached v1 directory, or it is older than <b>published</b>,
* then replace it with <b>directory</b>, published at <b>published</b>.
*
* If <b>published</b> is too old, do nothing.