aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-10-27 02:07:04 +0000
committerNick Mathewson <nickm@torproject.org>2006-10-27 02:07:04 +0000
commit5b72dc77ade9fc0b6c4d8b3aecd2d5b6f8400a3a (patch)
tree93176ce91894df211ae9befce28a7cc2cfdb75d5
parente624fe47338c2c0ff1027a63c27891c9a5d30932 (diff)
downloadtor-5b72dc77ade9fc0b6c4d8b3aecd2d5b6f8400a3a.tar.gz
tor-5b72dc77ade9fc0b6c4d8b3aecd2d5b6f8400a3a.zip
r9395@Kushana: nickm | 2006-10-26 22:06:51 -0400
Fix Bug 349: Have GETINFO network-status return even old routers, and use long nicknames where appropriate. Document this. svn:r8834
-rw-r--r--ChangeLog3
-rw-r--r--doc/control-spec.txt5
-rw-r--r--src/or/control.c3
-rw-r--r--src/or/dirserv.c21
-rw-r--r--src/or/or.h3
5 files changed, 27 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 293a0a9e1a..4a5d4cef8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,9 @@ Changes in version 0.1.2.3-alpha - 2006-10-??
can tell which events and features are supported.
- A new CLEARDNSCACHE signal to allow controllers to clear the
client-side DNS cache without expiring circuits.
+ - When the controller does a "GETINFO network-status", tell it about even
+ those routers whose descriptors are very old, and use long nicknames
+ where appropriate.
o Security bugfixes:
- When the user sends a NEWNYM signal, clear the client-side DNS
diff --git a/doc/control-spec.txt b/doc/control-spec.txt
index 798d10ef3e..7ac949bcda 100644
--- a/doc/control-spec.txt
+++ b/doc/control-spec.txt
@@ -369,7 +369,10 @@ $Id$
"network-status" -- a space-separated list of all known OR identities.
This is in the same format as the router-status line in directories;
- see tor-spec.txt for details.
+ see dir-spec-v1.txt section 3 for details. (If VERBOSE_NAMES is
+ enabled, the output will not conform to dir-spec-v1.txt; instead, the
+ result will be a space-separated list of LongName, each preceded by a
+ "!" if it is believed to be not running.)
"addr-mappings/all"
"addr-mappings/config"
diff --git a/src/or/control.c b/src/or/control.c
index 036323d2b4..baaaa29899 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1532,8 +1532,9 @@ handle_getinfo_helper(control_connection_t *control_conn,
strlen("unregistered-servers-"));
} else if (!strcmp(question, "network-status")) {
routerlist_t *routerlist = router_get_routerlist();
+ int verbose = control_conn->use_long_names;
if (!routerlist || !routerlist->routers ||
- list_server_status(routerlist->routers, answer) < 0) {
+ list_server_status(routerlist->routers, answer, verbose ? 2 : 1) < 0) {
return -1;
}
} else if (!strcmp(question, "circuit-status")) {
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index a63de5f8bc..c72c847983 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -566,7 +566,6 @@ dirserv_add_descriptor(const char *desc, const char **msg)
}
}
-
static INLINE int
bool_neq(int a, int b)
{
@@ -731,9 +730,13 @@ dirserv_thinks_router_is_blatantly_unreachable(routerinfo_t *router,
/** Based on the routerinfo_ts in <b>routers</b>, allocate the
* contents of a router-status line, and store it in
* *<b>router_status_out</b>. Return 0 on success, -1 on failure.
+ *
+ * If for_controller is true, include the routers with very old descriptors.
+ * If for_controller is &gt;1, use the verbose nickname format.
*/
int
-list_server_status(smartlist_t *routers, char **router_status_out)
+list_server_status(smartlist_t *routers, char **router_status_out,
+ int for_controller)
{
/* List of entries in a router-status style: An optional !, then an optional
* equals-suffixed nickname, then a dollar-prefixed hexdigest. */
@@ -751,8 +754,16 @@ list_server_status(smartlist_t *routers, char **router_status_out)
/* Update router status in routerinfo_t. */
ri->is_running = dirserv_thinks_router_is_reachable(ri, now);
}
- if (ri->cache_info.published_on >= cutoff)
+ if (for_controller == 1 || ri->cache_info.published_on >= cutoff)
smartlist_add(rs_entries, list_single_server_status(ri, ri->is_running));
+ else if (for_controller > 2) {
+ char name_buf[MAX_VERBOSE_NICKNAME_LEN+2];
+ char *cp = name_buf;
+ if (!ri->is_running)
+ *cp++ = '!';
+ router_get_verbose_nickname(cp, ri);
+ smartlist_add(rs_entries, tor_strdup(name_buf));
+ }
});
*router_status_out = smartlist_join_strings(rs_entries, " ", 0, NULL);
@@ -824,7 +835,7 @@ dirserv_dump_directory_to_string(char **dir_out,
tor_assert(dir_out);
*dir_out = NULL;
- if (list_server_status(rl->routers, &router_status))
+ if (list_server_status(rl->routers, &router_status, 0))
return -1;
if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,
@@ -1198,7 +1209,7 @@ generate_runningrouters(void)
size_t identity_pkey_len;
routerlist_t *rl = router_get_routerlist();
- if (list_server_status(rl->routers, &router_status)) {
+ if (list_server_status(rl->routers, &router_status, 0)) {
goto err;
}
if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,
diff --git a/src/or/or.h b/src/or/or.h
index bdae373601..6d9b27f127 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2189,7 +2189,8 @@ char *dirserver_getinfo_unregistered(const char *question);
void dirserv_free_descriptors(void);
int dirserv_thinks_router_is_blatantly_unreachable(routerinfo_t *router,
time_t now);
-int list_server_status(smartlist_t *routers, char **router_status_out);
+int list_server_status(smartlist_t *routers, char **router_status_out,
+ int for_controller);
int dirserv_dump_directory_to_string(char **dir_out,
crypto_pk_env_t *private_key,
int complete);