]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
running-routers now lists down routers too (with a ! before their name)
authorRoger Dingledine <arma@torproject.org>
Thu, 1 Jul 2004 11:32:26 +0000 (11:32 +0000)
committerRoger Dingledine <arma@torproject.org>
Thu, 1 Jul 2004 11:32:26 +0000 (11:32 +0000)
svn:r1996

src/or/dirserv.c
src/or/or.h
src/or/router.c

index 77b5f2a7a04db9d4c0c9359e8a49b83b6ecd8ff6..7de6a1e537ba90cfd7a5ef0ac42ef4876332b7b1 100644 (file)
@@ -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;
 }
 
index 12503e05d28071033fb0bd994a458cb6b427f3d4..08114af42c437ca49baad260f4d8a9581885127b 100644 (file)
@@ -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? */
 
index 308a1ad925a58cb4fae08c05aaad427a7dcce6c9..cd256e384227e6ba61472bb103310535518e5980 100644 (file)
@@ -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);