diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-10-27 02:07:04 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-10-27 02:07:04 +0000 |
commit | 5b72dc77ade9fc0b6c4d8b3aecd2d5b6f8400a3a (patch) | |
tree | 93176ce91894df211ae9befce28a7cc2cfdb75d5 /src | |
parent | e624fe47338c2c0ff1027a63c27891c9a5d30932 (diff) | |
download | tor-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
Diffstat (limited to 'src')
-rw-r--r-- | src/or/control.c | 3 | ||||
-rw-r--r-- | src/or/dirserv.c | 21 | ||||
-rw-r--r-- | src/or/or.h | 3 |
3 files changed, 20 insertions, 7 deletions
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 >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); |