mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Cache the parsed value of SafeLogging as an enum.
This commit is contained in:
parent
f258647433
commit
a8190b09a3
@ -893,7 +893,7 @@ const char *
|
|||||||
safe_str(const char *address)
|
safe_str(const char *address)
|
||||||
{
|
{
|
||||||
tor_assert(address);
|
tor_assert(address);
|
||||||
if (!strcmp(get_options()->SafeLogging, "1"))
|
if (get_options()->_SafeLogging == SAFELOG_SCRUB_ALL)
|
||||||
return "[scrubbed]";
|
return "[scrubbed]";
|
||||||
else
|
else
|
||||||
return address;
|
return address;
|
||||||
@ -906,8 +906,7 @@ const char *
|
|||||||
safe_str_relay(const char *address)
|
safe_str_relay(const char *address)
|
||||||
{
|
{
|
||||||
tor_assert(address);
|
tor_assert(address);
|
||||||
if (!strcmp(get_options()->SafeLogging, "1") ||
|
if (get_options()->_SafeLogging != SAFELOG_SCRUB_NONE)
|
||||||
!strcmp(get_options()->SafeLogging, "relay"))
|
|
||||||
return "[scrubbed]";
|
return "[scrubbed]";
|
||||||
else
|
else
|
||||||
return address;
|
return address;
|
||||||
@ -919,7 +918,7 @@ safe_str_relay(const char *address)
|
|||||||
const char *
|
const char *
|
||||||
escaped_safe_str(const char *address)
|
escaped_safe_str(const char *address)
|
||||||
{
|
{
|
||||||
if (!strcmp(get_options()->SafeLogging, "1"))
|
if (get_options()->_SafeLogging == SAFELOG_SCRUB_ALL)
|
||||||
return "[scrubbed]";
|
return "[scrubbed]";
|
||||||
else
|
else
|
||||||
return escaped(address);
|
return escaped(address);
|
||||||
@ -931,8 +930,7 @@ escaped_safe_str(const char *address)
|
|||||||
const char *
|
const char *
|
||||||
escaped_safe_str_relay(const char *address)
|
escaped_safe_str_relay(const char *address)
|
||||||
{
|
{
|
||||||
if (!strcasecmp(get_options()->SafeLogging, "1") ||
|
if (get_options()->_SafeLogging != SAFELOG_SCRUB_NONE)
|
||||||
!strcasecmp(get_options()->SafeLogging, "relay"))
|
|
||||||
return "[scrubbed]";
|
return "[scrubbed]";
|
||||||
else
|
else
|
||||||
return escaped(address);
|
return escaped(address);
|
||||||
@ -3382,14 +3380,17 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options->SafeLogging &&
|
if (!options->SafeLogging ||
|
||||||
!(!strcasecmp(options->SafeLogging, "relay") ||
|
!strcasecmp(options->SafeLogging, "0")) {
|
||||||
!strcasecmp(options->SafeLogging, "1") ||
|
options->_SafeLogging = SAFELOG_SCRUB_NONE;
|
||||||
!strcasecmp(options->SafeLogging, "0")))
|
} 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),
|
r = tor_snprintf(buf, sizeof(buf),
|
||||||
"Unrecognized value '%s' in SafeLogging",
|
"Unrecognized value '%s' in SafeLogging",
|
||||||
options->SafeLogging);
|
escaped(options->SafeLogging));
|
||||||
*msg = tor_strdup(r >= 0 ? buf : "internal error");
|
*msg = tor_strdup(r >= 0 ? buf : "internal error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2562,6 +2562,12 @@ typedef struct {
|
|||||||
int ShutdownWaitLength; /**< When we get a SIGINT and we're a server, how
|
int ShutdownWaitLength; /**< When we get a SIGINT and we're a server, how
|
||||||
* long do we wait before exiting? */
|
* long do we wait before exiting? */
|
||||||
char *SafeLogging; /**< Contains "relay", "1", "0" (meaning no scrubbing). */
|
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
|
int SafeSocks; /**< Boolean: should we outright refuse application
|
||||||
* connections that use socks4 or socks5-with-local-dns? */
|
* connections that use socks4 or socks5-with-local-dns? */
|
||||||
#define LOG_PROTOCOL_WARN (get_options()->ProtocolWarnings ? \
|
#define LOG_PROTOCOL_WARN (get_options()->ProtocolWarnings ? \
|
||||||
|
Loading…
Reference in New Issue
Block a user