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;
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;
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);
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);
});
}
- 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;
}
int ShutdownWaitLength; /**< When we get a SIGINT and we're a server, how
* long do we wait before exiting? */
char *SafeLogging; /**< Contains "relay", "1", "0" (meaning no scrubbing). */
+
+ /* Derived from SafeLogging */
+ enum {
+ SAFELOG_SCRUB_ALL, SAFELOG_SCRUB_RELAY, SAFELOG_SCRUB_NONE
+ } _SafeLogging;
+
int SafeSocks; /**< Boolean: should we outright refuse application
* connections that use socks4 or socks5-with-local-dns? */
#define LOG_PROTOCOL_WARN (get_options()->ProtocolWarnings ? \