mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
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
This commit is contained in:
+2
-1
@@ -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")) {
|
||||
|
||||
+16
-5
@@ -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 >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,
|
||||
|
||||
+2
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user