summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-12-06 07:15:06 +0000
committerRoger Dingledine <arma@torproject.org>2007-12-06 07:15:06 +0000
commit8de470cf690da38069766d827b5fd0a2a13960fe (patch)
treeafd526e3a8ee9c6f17f8c228f87f05f1a46ded91 /src
parent3ff63b6f4e7a6be2183124c6b3e6d9aeb70f029a (diff)
downloadtor-8de470cf690da38069766d827b5fd0a2a13960fe.tar.gz
tor-8de470cf690da38069766d827b5fd0a2a13960fe.zip
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. svn:r12687
Diffstat (limited to 'src')
-rw-r--r--src/or/control.c10
-rw-r--r--src/or/or.h1
-rw-r--r--src/or/routerlist.c11
3 files changed, 21 insertions, 1 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 5d0eda1a24..eda4be1970 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -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);
diff --git a/src/or/or.h b/src/or/or.h
index ddafcd3d20..fd5a15b015 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -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);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 524113c4bf..47c780830b 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -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)