From 0b4b51314f5cb0242e7a8fd3b87bc800cd04eacc Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 18 Jul 2010 17:05:58 +0200 Subject: 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. --- src/or/geoip.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/or/geoip.c') diff --git a/src/or/geoip.c b/src/or/geoip.c index ad28a77ffd..7f6cf79d8b 100644 --- a/src/or/geoip.c +++ b/src/or/geoip.c @@ -1318,10 +1318,15 @@ geoip_entry_stats_write(time_t now) /** Helper used to implement GETINFO ip-to-country/... controller command. */ int getinfo_helper_geoip(control_connection_t *control_conn, - const char *question, char **answer) + const char *question, char **answer, + const char **errmsg) { (void)control_conn; - if (geoip_is_loaded() && !strcmpstart(question, "ip-to-country/")) { + if (!geoip_is_loaded()) { + *errmsg = "GeoIP data not loaded"; + return -1; + } + if (!strcmpstart(question, "ip-to-country/")) { int c; uint32_t ip; struct in_addr in; -- cgit v1.2.3-54-g00ecf