[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] implement getinfo desc/all-recent



Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or

Modified Files:
	control.c 
Log Message:
implement getinfo desc/all-recent
closes bug 237.


Index: control.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -p -d -r1.162 -r1.163
--- control.c	9 Jan 2006 23:13:52 -0000	1.162
+++ control.c	10 Jan 2006 20:09:31 -0000	1.163
@@ -1247,6 +1247,7 @@ list_getinfo_options(void)
     "config/names List of configuration options, types, and documentation.\n"
     "desc/id/* Server descriptor by hex ID\n"
     "desc/name/* Server descriptor by nickname.\n"
+    "desc/all-recent Latest server descriptor for every router\n"
     "entry-nodes Which nodes will we use as entry nodes?\n"
     "info/names List of GETINFO options, types, and documentation.\n"
     "network-status List of hex IDs, nicknames, server statuses.\n"
@@ -1284,6 +1285,19 @@ handle_getinfo_helper(const char *questi
     routerinfo_t *ri = router_get_by_nickname(question+strlen("desc/name/"),1);
     if (ri && ri->cache_info.signed_descriptor)
       *answer = tor_strdup(ri->cache_info.signed_descriptor);
+  } else if (!strcmp(question, "desc/all-recent")) {
+    routerlist_t *routerlist = router_get_routerlist();
+    smartlist_t *sl = smartlist_create();
+    if (routerlist && routerlist->routers) {
+      SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, ri,
+      {
+      if (ri && ri->cache_info.signed_descriptor)
+        smartlist_add(sl, tor_strdup(ri->cache_info.signed_descriptor));
+      });
+    }
+    *answer = smartlist_join_strings(sl, "", 0, NULL);
+    SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
+    smartlist_free(sl);
   } else if (!strcmpstart(question, "unregistered-servers-")) {
     *answer = dirserver_getinfo_unregistered(question +
                                              strlen("unregistered-servers-"));