summaryrefslogtreecommitdiff
path: root/src/or/networkstatus.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-07-18 17:05:58 +0200
committerNick Mathewson <nickm@torproject.org>2010-07-18 17:05:58 +0200
commit0b4b51314f5cb0242e7a8fd3b87bc800cd04eacc (patch)
treea21f97794107eafb0f8e4192d88f8812b037ea62 /src/or/networkstatus.c
parent9d5d0f040f9b0ddf6c10166200d115bfa30a31da (diff)
downloadtor-0b4b51314f5cb0242e7a8fd3b87bc800cd04eacc.tar.gz
tor-0b4b51314f5cb0242e7a8fd3b87bc800cd04eacc.zip
Make the controller act more usefully when GETINFO fails
Right now it says "552 internal error" because there's no way for getinfo_helper_*() countries to specify an error message. This patch changes the getinfo_helper_*() interface, and makes most of the getinfo helpers give useful error messages in response to failures. This should prevent recurrences of bug 1699, where a missing GeoIPFile line in the torrc made GETINFO ip-to-county/* fail in a "not obvious how to fix" way.
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r--src/or/networkstatus.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 49bc8053ab..4834d13764 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -2124,7 +2124,8 @@ networkstatus_parse_flavor_name(const char *flavname)
* ORs. Return 0 on success, -1 on unrecognized question format. */
int
getinfo_helper_networkstatus(control_connection_t *conn,
- const char *question, char **answer)
+ const char *question, char **answer,
+ const char **errmsg)
{
routerstatus_t *status;
(void) conn;
@@ -2148,8 +2149,10 @@ getinfo_helper_networkstatus(control_connection_t *conn,
} else if (!strcmpstart(question, "ns/id/")) {
char d[DIGEST_LEN];
- if (base16_decode(d, DIGEST_LEN, question+6, strlen(question+6)))
+ if (base16_decode(d, DIGEST_LEN, question+6, strlen(question+6))) {
+ *errmsg = "Data not decodeable as hex";
return -1;
+ }
status = router_get_consensus_status_by_id(d);
} else if (!strcmpstart(question, "ns/name/")) {
status = router_get_consensus_status_by_nickname(question+8, 0);