]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add "GETINFO/desc-annotations/id/<OR digest>" so controllers can
authorRoger Dingledine <arma@torproject.org>
Thu, 6 Dec 2007 07:15:06 +0000 (07:15 +0000)
committerRoger Dingledine <arma@torproject.org>
Thu, 6 Dec 2007 07:15:06 +0000 (07:15 +0000)
ask about source, timestamp of arrival, purpose, etc. We need
something like this to help Vidalia not do GeoIP lookups on bridge
addresses.

svn:r12687

ChangeLog
doc/spec/control-spec.txt
doc/spec/proposals/126-geoip-reporting.txt
src/or/control.c
src/or/or.h
src/or/routerlist.c

index 7f37095cceaba8657c6f37d0df9d58bb141cbeb5..ccd9accc15a2e6667fabbbdc369d94f59a06157f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -49,6 +49,10 @@ Changes in version 0.2.0.13-alpha - 2007-12-??
       be a bridge relay. Right now the only difference is that it makes
       you answer begin_dir requests, and it makes you cache dir info,
       even if your DirPort isn't on.
+    - Add "GETINFO/desc-annotations/id/<OR digest>" so controllers can
+      ask about source, timestamp of arrival, purpose, etc. We need
+      something like this to help Vidalia not do GeoIP lookups on bridge
+      addresses.
 
 
 Changes in version 0.2.0.12-alpha - 2007-11-16
index 83b35feb770866a82a99967fcf05e1321c641840..dcb4ffa4c37e41885202cf3f3873cb48e7d3599b 100644 (file)
@@ -371,6 +371,10 @@ $Id$
     "desc/id/<OR identity>" or "desc/name/<OR nickname>" -- the latest
       server descriptor for a given OR, NUL-terminated.
 
+    "desc-annotations/id/<OR identity>" -- outputs the annotations string
+      (source, timestamp of arrival, purpose, etc) for the corresponding
+      descriptor. [First implemented in 0.2.0.13-alpha.]
+
     "extra-info/digest/<digest>"  -- the extrainfo document whose digest (in
       hex) is <digest>.  Only available if we're downloading extra-info
       documents.
index 88b484e34921c98bddb978a132f3da1d3fef5825..02d9bc76d0217784230770c920a115d5df5fa7a2 100644 (file)
@@ -148,8 +148,7 @@ Status: Open
   that might want to map its relay locations. The best answer is that it
   should learn the router annotations, with a new controller 'getinfo'
   command:
-    "GETINFO router-annotations/id/<OR identity>" or
-    "GETINFO router-annotations/name/<OR nickname>"
+    "GETINFO desc-annotations/id/<OR identity>"
   which would respond with something like
     @downloaded-at 2007-11-29 08:06:38
     @source "128.31.0.34"
index 5d0eda1a246e0ee99b6e31f5679839b34dab8c0b..eda4be197056cc7a79fba376af4b1a389a96c5b5 100644 (file)
@@ -1356,6 +1356,16 @@ getinfo_helper_dir(control_connection_t *control_conn,
     *answer = smartlist_join_strings(sl, "", 0, NULL);
     SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
     smartlist_free(sl);
+  } else if (!strcmpstart(question, "desc-annotations/id/")) {
+    routerinfo_t *ri = router_get_by_hexdigest(question+
+                                               strlen("desc-annotations/id/"));
+    if (ri) {
+      const char *annotations =
+        signed_descriptor_get_annotations(&ri->cache_info);
+      if (annotations)
+        *answer = tor_strndup(annotations,
+                              ri->cache_info.signed_annotations_len);
+    }
   } else if (!strcmpstart(question, "dir/server/")) {
     size_t answer_len = 0, url_len = strlen(question)+2;
     char *url = tor_malloc(url_len);
index ddafcd3d203ae758a0eb4a78907ca5388e7910ee..fd5a15b015f00e690d2791cf528f756a3ea7c725 100644 (file)
@@ -3810,6 +3810,7 @@ signed_descriptor_t *router_get_by_descriptor_digest(const char *digest);
 signed_descriptor_t *router_get_by_extrainfo_digest(const char *digest);
 signed_descriptor_t *extrainfo_get_by_descriptor_digest(const char *digest);
 const char *signed_descriptor_get_body(signed_descriptor_t *desc);
+const char *signed_descriptor_get_annotations(signed_descriptor_t *desc);
 routerlist_t *router_get_routerlist(void);
 void routerinfo_free(routerinfo_t *router);
 void extrainfo_free(extrainfo_t *extrainfo);
index 524113c4bfe9c308d79e8425dc3d4eb1812391fc..47c780830bd14d62d02c2098d55ad05b1c16bf47 100644 (file)
@@ -1966,7 +1966,8 @@ extrainfo_get_by_descriptor_digest(const char *digest)
  * The returned string is not guaranteed to be NUL-terminated: the string's
  * length will be in desc-\>signed_descriptor_len.
  *
- * If with_annotations is set, the returned string will include the annotations
+ * If <b>with_annotations</b> is set, the returned string will include
+ * the annotations
  * (if any) preceding the descriptor.  This will increase the length of the
  * string by desc-\>annotations_len.
  *
@@ -2020,6 +2021,14 @@ signed_descriptor_get_body(signed_descriptor_t *desc)
   return signed_descriptor_get_body_impl(desc, 0);
 }
 
+/** As signed_descriptor_get_body(), but points to the beginning of the
+ * annotations section rather than the beginning of the descriptor. */
+const char *
+signed_descriptor_get_annotations(signed_descriptor_t *desc)
+{
+  return signed_descriptor_get_body_impl(desc, 1);
+}
+
 /** Return the current list of all known routers. */
 routerlist_t *
 router_get_routerlist(void)