[tor-commits] [tor/master] add new GETINFO config/defaults

nickm at torproject.org nickm at torproject.org
Thu Jun 28 19:18:18 UTC 2012


commit 12298901fd6a8ce0608129cf9e65dfc32d161a57
Author: meejah <meejah at meejah.ca>
Date:   Thu Apr 5 15:17:30 2012 -0600

    add new GETINFO config/defaults
    
    returns the default values for every configuration item, similar
    to GETINFO config/names; include a changes entry for it.
    
    Fix for bug 4971
---
 changes/bug4971  |    2 ++
 src/or/config.c  |   14 ++++++++++++++
 src/or/control.c |    3 +++
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/changes/bug4971 b/changes/bug4971
new file mode 100644
index 0000000..8c7d830
--- /dev/null
+++ b/changes/bug4971
@@ -0,0 +1,2 @@
+ o Minor Feature:
+   - Provide default values for all options via "GETINFO config/defaults"
diff --git a/src/or/config.c b/src/or/config.c
index 042fc1a..ceb21b0 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -7180,6 +7180,20 @@ getinfo_helper_config(control_connection_t *conn,
     *answer = smartlist_join_strings(sl, "", 0, NULL);
     SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
     smartlist_free(sl);
+  } else if (!strcmp(question, "config/defaults")) {
+    smartlist_t *sl = smartlist_new();
+    int i;
+    for (i = 0; _option_vars[i].name; ++i) {
+      const config_var_t *var = &_option_vars[i];
+      if (var->initvalue != NULL) {
+          char *val = esc_for_log(var->initvalue);
+          smartlist_add_asprintf(sl, "%s %s\n",var->name,val);
+          tor_free(val);
+      }
+    }
+    *answer = smartlist_join_strings(sl, "", 0, NULL);
+    SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
+    smartlist_free(sl);
   }
   return 0;
 }
diff --git a/src/or/control.c b/src/or/control.c
index 6675c01..0387f4b 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2123,6 +2123,9 @@ static const getinfo_item_t getinfo_items[] = {
   PREFIX("config/", config, "Current configuration values."),
   DOC("config/names",
       "List of configuration options, types, and documentation."),
+  DOC("config/defaults",
+      "List of default values for configuration options. "
+      "See also config/names"),
   ITEM("info/names", misc,
        "List of GETINFO options, types, and documentation."),
   ITEM("events/names", misc,



More information about the tor-commits mailing list