summaryrefslogtreecommitdiff
path: root/src/or/dirserv.c
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2005-10-18 17:09:57 +0000
committerPeter Palfrader <peter@palfrader.org>2005-10-18 17:09:57 +0000
commitd8daa910a66ccfbd25afa57e22e1a77090a8bb5c (patch)
tree920cf1645447ec0fadf50aa0d24670838ab9f657 /src/or/dirserv.c
parent551e3402a3a82eaf92c495564e0a5f4b7ab80fe4 (diff)
downloadtor-d8daa910a66ccfbd25afa57e22e1a77090a8bb5c.tar.gz
tor-d8daa910a66ccfbd25afa57e22e1a77090a8bb5c.zip
Make dirserv_get_routerdescs() return better http 404 error messages instead of a generic "Servers unavailable."
svn:r5274
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r--src/or/dirserv.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 3c413e3c20..dab99477ae 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1393,13 +1393,23 @@ dirserv_get_networkstatus_v2(smartlist_t *result,
* hex identity digests; or
* - "/tor/server/d/D" where D is a plus-separated sequence
* of server descriptor digests, in hex.
+ *
+ * Return -1 if we do not have any descriptors, no matching descriptors,
+ * or if we did not recognize the key (URL), 0 otherwise (i.e. we found some
+ * matching descriptors). If -1 is returned <b>msg</b> will be set to
+ * an appropriate error message.
*/
-void
-dirserv_get_routerdescs(smartlist_t *descs_out, const char *key)
+int
+dirserv_get_routerdescs(smartlist_t *descs_out, const char *key,
+ const char **msg)
{
smartlist_t *complete_list = get_descriptor_list();
- if (!complete_list)
- return;
+ *msg = NULL;
+
+ if (!complete_list) {
+ *msg = "No server descriptors available";
+ return -1;
+ }
if (!strcmp(key, "/tor/server/all")) {
smartlist_add_all(descs_out, complete_list);
@@ -1435,7 +1445,16 @@ dirserv_get_routerdescs(smartlist_t *descs_out, const char *key)
});
SMARTLIST_FOREACH(digests, char *, d, tor_free(d));
smartlist_free(digests);
+ } else {
+ *msg = "Key not recognized";
+ return -1;
}
+
+ if (!smartlist_len(descs_out)) {
+ *msg = "Servers unavailable";
+ return -1;
+ }
+ return 0;
}
/** Called when a TLS handshake has completed successfully with a