[or-cvs] r8834: Fix Bug 349: Have GETINFO network-status return even old rou (in tor/trunk: . doc src/or)
nickm at seul.org
nickm at seul.org
Fri Oct 27 02:07:08 UTC 2006
Author: nickm
Date: 2006-10-26 22:07:04 -0400 (Thu, 26 Oct 2006)
New Revision: 8834
Modified:
tor/trunk/
tor/trunk/ChangeLog
tor/trunk/doc/control-spec.txt
tor/trunk/src/or/control.c
tor/trunk/src/or/dirserv.c
tor/trunk/src/or/or.h
Log:
r9395 at 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.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r9395] on c95137ef-5f19-0410-b913-86e773d04f59
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2006-10-26 15:55:11 UTC (rev 8833)
+++ tor/trunk/ChangeLog 2006-10-27 02:07:04 UTC (rev 8834)
@@ -32,6 +32,9 @@
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
Modified: tor/trunk/doc/control-spec.txt
===================================================================
--- tor/trunk/doc/control-spec.txt 2006-10-26 15:55:11 UTC (rev 8833)
+++ tor/trunk/doc/control-spec.txt 2006-10-27 02:07:04 UTC (rev 8834)
@@ -369,7 +369,10 @@
"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"
Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c 2006-10-26 15:55:11 UTC (rev 8833)
+++ tor/trunk/src/or/control.c 2006-10-27 02:07:04 UTC (rev 8834)
@@ -1532,8 +1532,9 @@
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")) {
Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c 2006-10-26 15:55:11 UTC (rev 8833)
+++ tor/trunk/src/or/dirserv.c 2006-10-27 02:07:04 UTC (rev 8834)
@@ -566,7 +566,6 @@
}
}
-
static INLINE int
bool_neq(int a, int b)
{
@@ -731,9 +730,13 @@
/** 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 >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 @@
/* 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 @@
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 @@
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,
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2006-10-26 15:55:11 UTC (rev 8833)
+++ tor/trunk/src/or/or.h 2006-10-27 02:07:04 UTC (rev 8834)
@@ -2189,7 +2189,8 @@
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);
More information about the tor-commits
mailing list