[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Return a descriptive error for 'GETINFO status/fresh-relay-descs'



commit 8e59b8560a4ce372497ea7bf5bcddff0c5211ebc
Author: Neel Chauhan <neel@xxxxxxxxx>
Date:   Sun Apr 12 13:13:50 2020 -0700

    Return a descriptive error for 'GETINFO status/fresh-relay-descs'
---
 changes/ticket32873                   |  6 ++++++
 src/feature/control/control_getinfo.c | 18 ++++++++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/changes/ticket32873 b/changes/ticket32873
new file mode 100644
index 000000000..65ea1f64a
--- /dev/null
+++ b/changes/ticket32873
@@ -0,0 +1,6 @@
+  o Minor features (control port):
+    - Return a descriptive error message from the 'GETINFO
+      status/fresh-relay-descs' command on the control port.
+      Previously, we returned a generic error of "Error
+      generating descriptor". Closes ticket 32873. Patch by
+      Neel Chauhan.
diff --git a/src/feature/control/control_getinfo.c b/src/feature/control/control_getinfo.c
index 5dcc4b170..aa951e74f 100644
--- a/src/feature/control/control_getinfo.c
+++ b/src/feature/control/control_getinfo.c
@@ -1331,8 +1331,22 @@ getinfo_helper_events(control_connection_t *control_conn,
       }
       routerinfo_t *r;
       extrainfo_t *e;
-      if (router_build_fresh_descriptor(&r, &e) < 0) {
-        *errmsg = "Error generating descriptor";
+      int result;
+      if ((result = router_build_fresh_descriptor(&r, &e)) < 0) {
+        switch (result) {
+          case TOR_ROUTERINFO_ERROR_NO_EXT_ADDR:
+            *errmsg = "Cannot get relay address while generating descriptor";
+            break;
+          case TOR_ROUTERINFO_ERROR_DIGEST_FAILED:
+            *errmsg = "Key digest failed";
+            break;
+          case TOR_ROUTERINFO_ERROR_CANNOT_GENERATE:
+            *errmsg = "Cannot generate router descriptor";
+            break;
+          default:
+            *errmsg = "Error generating descriptor";
+            break;
+        }
         return -1;
       }
       size_t size = r->cache_info.signed_descriptor_len + 1;



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits