From: meejah Date: Thu, 5 Apr 2012 21:17:30 +0000 (-0600) Subject: add new GETINFO config/defaults X-Git-Tag: tor-0.2.4.1-alpha~108 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=12298901fd6a8ce0608129cf9e65dfc32d161a57;p=thirdparty%2Ftor.git 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 --- diff --git a/changes/bug4971 b/changes/bug4971 new file mode 100644 index 0000000000..8c7d830ca4 --- /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 042fc1aa3c..ceb21b0cf0 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 6675c01b63..0387f4b2ee 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,