aboutsummaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-12-12 01:12:47 -0500
committerNick Mathewson <nickm@torproject.org>2009-12-12 01:12:47 -0500
commita8190b09a319bf6b1bac7608ea77f828f9970056 (patch)
treee5a103663dfe6b4e393b736600ad4f531384763b /src/or/config.c
parentf25864743368e7962bfffc0e57763b13157429e3 (diff)
downloadtor-a8190b09a319bf6b1bac7608ea77f828f9970056.tar.gz
tor-a8190b09a319bf6b1bac7608ea77f828f9970056.zip
Cache the parsed value of SafeLogging as an enum.
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/or/config.c b/src/or/config.c
index bd7fe22946..0fb1767928 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -893,7 +893,7 @@ const char *
safe_str(const char *address)
{
tor_assert(address);
- if (!strcmp(get_options()->SafeLogging, "1"))
+ if (get_options()->_SafeLogging == SAFELOG_SCRUB_ALL)
return "[scrubbed]";
else
return address;
@@ -906,8 +906,7 @@ const char *
safe_str_relay(const char *address)
{
tor_assert(address);
- if (!strcmp(get_options()->SafeLogging, "1") ||
- !strcmp(get_options()->SafeLogging, "relay"))
+ if (get_options()->_SafeLogging != SAFELOG_SCRUB_NONE)
return "[scrubbed]";
else
return address;
@@ -919,7 +918,7 @@ safe_str_relay(const char *address)
const char *
escaped_safe_str(const char *address)
{
- if (!strcmp(get_options()->SafeLogging, "1"))
+ if (get_options()->_SafeLogging == SAFELOG_SCRUB_ALL)
return "[scrubbed]";
else
return escaped(address);
@@ -931,8 +930,7 @@ escaped_safe_str(const char *address)
const char *
escaped_safe_str_relay(const char *address)
{
- if (!strcasecmp(get_options()->SafeLogging, "1") ||
- !strcasecmp(get_options()->SafeLogging, "relay"))
+ if (get_options()->_SafeLogging != SAFELOG_SCRUB_NONE)
return "[scrubbed]";
else
return escaped(address);
@@ -3382,14 +3380,17 @@ options_validate(or_options_t *old_options, or_options_t *options,
});
}
- if (options->SafeLogging &&
- !(!strcasecmp(options->SafeLogging, "relay") ||
- !strcasecmp(options->SafeLogging, "1") ||
- !strcasecmp(options->SafeLogging, "0")))
- {
+ if (!options->SafeLogging ||
+ !strcasecmp(options->SafeLogging, "0")) {
+ options->_SafeLogging = SAFELOG_SCRUB_NONE;
+ } else if (!strcasecmp(options->SafeLogging, "relay")) {
+ options->_SafeLogging = SAFELOG_SCRUB_RELAY;
+ } else if (!strcasecmp(options->SafeLogging, "1")) {
+ options->_SafeLogging = SAFELOG_SCRUB_ALL;
+ } else {
r = tor_snprintf(buf, sizeof(buf),
"Unrecognized value '%s' in SafeLogging",
- options->SafeLogging);
+ escaped(options->SafeLogging));
*msg = tor_strdup(r >= 0 ? buf : "internal error");
return -1;
}