mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
r14203@Kushana: nickm | 2007-08-24 10:15:58 -0400
Add a hacked-up GETINFO desc/all-recent-extrainfo-hack so that torstat can keep working with a minimum of fuss, until it learns about extrainfo documents. svn:r11269
This commit is contained in:
parent
cf2ac9b9e1
commit
b9d43e2685
@ -32,6 +32,10 @@ Changes in version 0.2.0.6-alpha - 2007-??-??
|
|||||||
address family. Addresses but does not wholly fix bug 483. (Bugfix
|
address family. Addresses but does not wholly fix bug 483. (Bugfix
|
||||||
on 0.2.0.x)
|
on 0.2.0.x)
|
||||||
|
|
||||||
|
o Minor features (controller):
|
||||||
|
- There is now an ugly, temporary "desc/all-recent-extrainfo-hack"
|
||||||
|
GETINFO for Torstat to use into it can switch to use extrainfos.
|
||||||
|
|
||||||
o Minor bugfixes (misc):
|
o Minor bugfixes (misc):
|
||||||
- Let directory authorities startup even when they can't generate
|
- Let directory authorities startup even when they can't generate
|
||||||
a descriptor immediately, e.g. because they don't know their
|
a descriptor immediately, e.g. because they don't know their
|
||||||
|
@ -1230,6 +1230,48 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** DOCDOC */
|
||||||
|
static char *
|
||||||
|
munge_extrainfo_into_routerinfo(const char *ri_body, signed_descriptor_t *ri,
|
||||||
|
signed_descriptor_t *ei)
|
||||||
|
{
|
||||||
|
char *out = NULL, *outp;
|
||||||
|
int i;
|
||||||
|
const char *router_sig;
|
||||||
|
const char *ei_body = signed_descriptor_get_body(ei);
|
||||||
|
size_t ri_len = ri->signed_descriptor_len;
|
||||||
|
size_t ei_len = ei->signed_descriptor_len;
|
||||||
|
if (!ei_body)
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
outp = out = tor_malloc(ri_len+ei_len+1);
|
||||||
|
if (!(router_sig = tor_memstr(ri_body, ri_len, "\nrouter-signature")))
|
||||||
|
goto bail;
|
||||||
|
++router_sig;
|
||||||
|
memcpy(out, ri_body, router_sig-ri_body);
|
||||||
|
outp += router_sig-ri_body;
|
||||||
|
|
||||||
|
for (i=0; i < 2; ++i) {
|
||||||
|
const char *kwd = i?"\nwrite-history ":"\nread-history ";
|
||||||
|
const char *cp, *eol;
|
||||||
|
if (!(cp = tor_memstr(ei_body, ei_len, kwd)))
|
||||||
|
continue;
|
||||||
|
++cp;
|
||||||
|
eol = memchr(cp, '\n', ei_len - (cp-ei_body));
|
||||||
|
memcpy(outp, cp, eol-cp+1);
|
||||||
|
outp += eol-cp+1;
|
||||||
|
}
|
||||||
|
memcpy(outp, router_sig, ri_len - (router_sig-ri_body));
|
||||||
|
*outp++ = '\0';
|
||||||
|
tor_assert(outp-out < (int)(ri_len+ei_len+1));
|
||||||
|
|
||||||
|
return out;
|
||||||
|
bail:
|
||||||
|
tor_free(out);
|
||||||
|
return tor_strndup(ri_body, ri->signed_descriptor_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Implementation helper for GETINFO: knows the answers for questions about
|
/** Implementation helper for GETINFO: knows the answers for questions about
|
||||||
* directory information. */
|
* directory information. */
|
||||||
static int
|
static int
|
||||||
@ -1265,6 +1307,28 @@ getinfo_helper_dir(control_connection_t *control_conn,
|
|||||||
*answer = smartlist_join_strings(sl, "", 0, NULL);
|
*answer = smartlist_join_strings(sl, "", 0, NULL);
|
||||||
SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
|
SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
|
||||||
smartlist_free(sl);
|
smartlist_free(sl);
|
||||||
|
} else if (!strcmp(question, "desc/all-recent-extrainfo-hack")) {
|
||||||
|
/* XXXX Remove this once Torstat asks for extrainfos. */
|
||||||
|
routerlist_t *routerlist = router_get_routerlist();
|
||||||
|
smartlist_t *sl = smartlist_create();
|
||||||
|
if (routerlist && routerlist->routers) {
|
||||||
|
SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, ri,
|
||||||
|
{
|
||||||
|
const char *body = signed_descriptor_get_body(&ri->cache_info);
|
||||||
|
signed_descriptor_t *ei = extrainfo_get_by_descriptor_digest(
|
||||||
|
ri->cache_info.signed_descriptor_digest);
|
||||||
|
if (ei && body) {
|
||||||
|
smartlist_add(sl, munge_extrainfo_into_routerinfo(body,
|
||||||
|
&ri->cache_info, ei));
|
||||||
|
} else if (body) {
|
||||||
|
smartlist_add(sl,
|
||||||
|
tor_strndup(body, ri->cache_info.signed_descriptor_len));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
*answer = smartlist_join_strings(sl, "", 0, NULL);
|
||||||
|
SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
|
||||||
|
smartlist_free(sl);
|
||||||
} else if (!strcmpstart(question, "dir/server/")) {
|
} else if (!strcmpstart(question, "dir/server/")) {
|
||||||
size_t answer_len = 0, url_len = strlen(question)+2;
|
size_t answer_len = 0, url_len = strlen(question)+2;
|
||||||
char *url = tor_malloc(url_len);
|
char *url = tor_malloc(url_len);
|
||||||
@ -1584,6 +1648,7 @@ static const getinfo_item_t getinfo_items[] = {
|
|||||||
PREFIX("desc/name/", dir, "Router descriptors by nickname."),
|
PREFIX("desc/name/", dir, "Router descriptors by nickname."),
|
||||||
ITEM("desc/all-recent", dir,
|
ITEM("desc/all-recent", dir,
|
||||||
"All non-expired, non-superseded router descriptors."),
|
"All non-expired, non-superseded router descriptors."),
|
||||||
|
ITEM("desc/all-recent-extrainfo-hack", dir, NULL), /* Hack. */
|
||||||
ITEM("ns/all", networkstatus,
|
ITEM("ns/all", networkstatus,
|
||||||
"Brief summary of router status (v2 directory format)"),
|
"Brief summary of router status (v2 directory format)"),
|
||||||
PREFIX("ns/id/", networkstatus,
|
PREFIX("ns/id/", networkstatus,
|
||||||
|
Loading…
Reference in New Issue
Block a user