|
@@ -49,6 +49,8 @@ typedef enum config_type_t {
|
|
|
CONFIG_TYPE_MEMUNIT, /**< A number of bytes, with optional units*/
|
|
|
CONFIG_TYPE_DOUBLE, /**< A floating-point value */
|
|
|
CONFIG_TYPE_BOOL, /**< A boolean value, expressed as 0 or 1. */
|
|
|
+ CONFIG_TYPE_AUTOBOOL, /**< A boolean+auto value, expressed 0 for false,
|
|
|
+ * 1 for true, and -1 for auto */
|
|
|
CONFIG_TYPE_ISOTIME, /**< An ISO-formatted time relative to GMT. */
|
|
|
CONFIG_TYPE_CSV, /**< A list of strings, separated by commas and
|
|
|
* optional whitespace. */
|
|
@@ -338,7 +340,7 @@ static config_var_t _option_vars[] = {
|
|
|
V(RecommendedClientVersions, LINELIST, NULL),
|
|
|
V(RecommendedServerVersions, LINELIST, NULL),
|
|
|
OBSOLETE("RedirectExit"),
|
|
|
- V(RefuseUnknownExits, STRING, "auto"),
|
|
|
+ V(RefuseUnknownExits, AUTOBOOL, "auto"),
|
|
|
V(RejectPlaintextPorts, CSV, ""),
|
|
|
V(RelayBandwidthBurst, MEMUNIT, "0"),
|
|
|
V(RelayBandwidthRate, MEMUNIT, "0"),
|
|
@@ -1271,18 +1273,6 @@ options_act(or_options_t *old_options)
|
|
|
connection_bucket_init();
|
|
|
#endif
|
|
|
|
|
|
- /* parse RefuseUnknownExits tristate */
|
|
|
- if (!strcmp(options->RefuseUnknownExits, "0"))
|
|
|
- options->RefuseUnknownExits_ = 0;
|
|
|
- else if (!strcmp(options->RefuseUnknownExits, "1"))
|
|
|
- options->RefuseUnknownExits_ = 1;
|
|
|
- else if (!strcmp(options->RefuseUnknownExits, "auto"))
|
|
|
- options->RefuseUnknownExits_ = -1;
|
|
|
- else {
|
|
|
- /* Should have caught this in options_validate */
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
/* Change the cell EWMA settings */
|
|
|
cell_ewma_set_scale_factor(options, networkstatus_get_latest_consensus());
|
|
|
|
|
@@ -1788,6 +1778,20 @@ config_assign_value(config_format_t *fmt, or_options_t *options,
|
|
|
*(int *)lvalue = i;
|
|
|
break;
|
|
|
|
|
|
+ case CONFIG_TYPE_AUTOBOOL:
|
|
|
+ if (!strcmp(c->value, "auto"))
|
|
|
+ *(int *)lvalue = -1;
|
|
|
+ else if (!strcmp(c->value, "0"))
|
|
|
+ *(int *)lvalue = 0;
|
|
|
+ else if (!strcmp(c->value, "1"))
|
|
|
+ *(int *)lvalue = 1;
|
|
|
+ else {
|
|
|
+ tor_asprintf(msg, "Boolean '%s %s' expects 0, 1, or 'auto'.",
|
|
|
+ c->key, c->value);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
case CONFIG_TYPE_STRING:
|
|
|
case CONFIG_TYPE_FILENAME:
|
|
|
tor_free(*(char **)lvalue);
|
|
@@ -2068,6 +2072,14 @@ get_assigned_option(config_format_t *fmt, void *options,
|
|
|
tor_asprintf(&result->value, "%f", *(double*)value);
|
|
|
escape_val = 0; /* Can't need escape. */
|
|
|
break;
|
|
|
+
|
|
|
+ case CONFIG_TYPE_AUTOBOOL:
|
|
|
+ if (*(int*)value == -1) {
|
|
|
+ result->value = tor_strdup("auto");
|
|
|
+ escape_val = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ /* fall through */
|
|
|
case CONFIG_TYPE_BOOL:
|
|
|
result->value = tor_strdup(*(int*)value ? "1" : "0");
|
|
|
escape_val = 0; /* Can't need escape. */
|
|
@@ -2285,6 +2297,9 @@ option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
|
|
|
case CONFIG_TYPE_BOOL:
|
|
|
*(int*)lvalue = 0;
|
|
|
break;
|
|
|
+ case CONFIG_TYPE_AUTOBOOL:
|
|
|
+ *(int*)lvalue = -1;
|
|
|
+ break;
|
|
|
case CONFIG_TYPE_MEMUNIT:
|
|
|
*(uint64_t*)lvalue = 0;
|
|
|
break;
|
|
@@ -3014,12 +3029,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|
|
REJECT("Failed to resolve/guess local address. See logs for details.");
|
|
|
}
|
|
|
|
|
|
- if (strcmp(options->RefuseUnknownExits, "0") &&
|
|
|
- strcmp(options->RefuseUnknownExits, "1") &&
|
|
|
- strcmp(options->RefuseUnknownExits, "auto")) {
|
|
|
- REJECT("RefuseUnknownExits must be 0, 1, or auto");
|
|
|
- }
|
|
|
-
|
|
|
#ifndef MS_WINDOWS
|
|
|
if (options->RunAsDaemon && torrc_fname && path_is_relative(torrc_fname))
|
|
|
REJECT("Can't use a relative path to torrc when RunAsDaemon is set.");
|
|
@@ -5408,6 +5417,7 @@ getinfo_helper_config(control_connection_t *conn,
|
|
|
case CONFIG_TYPE_MEMUNIT: type = "DataSize"; break;
|
|
|
case CONFIG_TYPE_DOUBLE: type = "Float"; break;
|
|
|
case CONFIG_TYPE_BOOL: type = "Boolean"; break;
|
|
|
+ case CONFIG_TYPE_AUTOBOOL: type = "Boolean+Auto"; break;
|
|
|
case CONFIG_TYPE_ISOTIME: type = "Time"; break;
|
|
|
case CONFIG_TYPE_ROUTERSET: type = "RouterList"; break;
|
|
|
case CONFIG_TYPE_CSV: type = "CommaList"; break;
|