aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-07-01 11:32:26 +0000
committerRoger Dingledine <arma@torproject.org>2004-07-01 11:32:26 +0000
commite1ba0c466341a883394d446c0ad81855c1076b9d (patch)
tree707d1f334a1d534028db5228bae113e224071b1e /src
parent53b21c65f7f8c5cb4a4a84b16c6d5011063a7280 (diff)
downloadtor-e1ba0c466341a883394d446c0ad81855c1076b9d.tar
tor-e1ba0c466341a883394d446c0ad81855c1076b9d.tar.gz
running-routers now lists down routers too (with a ! before their name)
svn:r1996
Diffstat (limited to 'src')
-rw-r--r--src/or/dirserv.c41
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/router.c2
3 files changed, 28 insertions, 17 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 77b5f2a7a..7de6a1e53 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -442,36 +442,47 @@ list_running_servers(char **nicknames_out)
char *cp;
int i;
int length;
- smartlist_t *nicknames;
+ smartlist_t *nicknames_up, *nicknames_down;
*nicknames_out = NULL;
- nicknames = smartlist_create();
- smartlist_add(nicknames, options.Nickname);
+ nicknames_up = smartlist_create();
+ nicknames_down = smartlist_create();
+ smartlist_add(nicknames_up, options.Nickname);
get_connection_array(&connection_array, &n_conns);
for (i = 0; i<n_conns; ++i) {
conn = connection_array[i];
- if (conn->type != CONN_TYPE_OR || conn->state != OR_CONN_STATE_OPEN)
- continue; /* only list successfully handshaked OR's. */
- if(!conn->nickname) /* it's an OP, don't list it */
- continue;
- /* XXX008 need to change this to list "!nickname" for down routers */
+ if (conn->type != CONN_TYPE_OR || !conn->nickname)
+ continue; /* only list ORs. */
if (!router_nickname_is_approved(conn->nickname))
continue; /* If we removed them from the approved list, don't list it.*/
- smartlist_add(nicknames, conn->nickname);
- }
- length = smartlist_len(nicknames) + 1; /* spaces + EOS + 1. */
- SMARTLIST_FOREACH(nicknames, char *, c, length += strlen(c));
+ if(conn->state == OR_CONN_STATE_OPEN)
+ smartlist_add(nicknames_up, conn->nickname);
+ else
+ smartlist_add(nicknames_down, conn->nickname);
+ }
+ length = smartlist_len(nicknames_up) +
+ 2*smartlist_len(nicknames_down) + 1;
+ /* spaces + EOS + !'s + 1. */
+ SMARTLIST_FOREACH(nicknames_up, char *, c, length += strlen(c));
+ SMARTLIST_FOREACH(nicknames_down, char *, c, length += strlen(c));
*nicknames_out = tor_malloc_zero(length);
cp = *nicknames_out;
- for (i = 0; i<smartlist_len(nicknames); ++i) {
+ for (i = 0; i<smartlist_len(nicknames_up); ++i) {
if (i)
strcat(cp, " ");
- strcat(cp, (char*)smartlist_get(nicknames,i)); /* can't overflow */
+ strcat(cp, (char*)smartlist_get(nicknames_up,i)); /* can't overflow */
+ while (*cp)
+ ++cp;
+ }
+ for (i = 0; i<smartlist_len(nicknames_down); ++i) {
+ strcat(cp, " !");
+ strcat(cp, (char*)smartlist_get(nicknames_down,i)); /* can't overflow */
while (*cp)
++cp;
}
- smartlist_free(nicknames);
+ smartlist_free(nicknames_up);
+ smartlist_free(nicknames_down);
return 0;
}
diff --git a/src/or/or.h b/src/or/or.h
index 12503e05d..08114af42 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -570,7 +570,7 @@ typedef struct {
crypto_pk_env_t *onion_pkey; /**< Public RSA key for onions. */
crypto_pk_env_t *identity_pkey; /**< Public RSA key for signing. */
- char identity_digest[DIGEST_LEN]; /** Digest of identity key */
+ char identity_digest[DIGEST_LEN]; /**< Digest of identity key */
char *platform; /**< What software/operating system is this OR using? */
diff --git a/src/or/router.c b/src/or/router.c
index 308a1ad92..cd256e384 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -285,7 +285,7 @@ int init_keys(void) {
if(!cp) {
log_fn(LOG_INFO,"Cached directory %s not present. Ok.",keydir);
} else {
- if(options.AuthoritativeDir)
+ if(options.AuthoritativeDir) {
if(dirserv_load_from_directory_string(cp) < 0){
log_fn(LOG_ERR, "Cached directory %s is corrupt", keydir);
tor_free(cp);