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
This commit is contained in:
meejah 2012-04-05 15:17:30 -06:00 committed by Nick Mathewson
parent 58eb3e405d
commit 12298901fd
3 changed files with 19 additions and 0 deletions

2
changes/bug4971 Normal file
View File

@ -0,0 +1,2 @@
o Minor Feature:
- Provide default values for all options via "GETINFO config/defaults"

View File

@ -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;
}

View File

@ -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,