Commit 238a9080 authored by haxxpop's avatar haxxpop
Browse files

hs-v3: add an option param to safe log functions

We add an option param to safe_str and safe_str_client because in
some case we need to use those functions before global_options is set.
parent 8de735f0
...@@ -1086,10 +1086,14 @@ config_free_all(void) ...@@ -1086,10 +1086,14 @@ config_free_all(void)
* (We return "[scrubbed]" if SafeLogging is "1", and address otherwise.) * (We return "[scrubbed]" if SafeLogging is "1", and address otherwise.)
*/ */
const char * const char *
safe_str_client(const char *address) safe_str_client_opts(const or_options_t *options, const char *address)
{ {
tor_assert(address); tor_assert(address);
if (get_options()->SafeLogging_ == SAFELOG_SCRUB_ALL) if (!options) {
options = get_options();
}
if (options->SafeLogging_ == SAFELOG_SCRUB_ALL)
return "[scrubbed]"; return "[scrubbed]";
else else
return address; return address;
...@@ -1103,10 +1107,14 @@ safe_str_client(const char *address) ...@@ -1103,10 +1107,14 @@ safe_str_client(const char *address)
* otherwise.) * otherwise.)
*/ */
const char * const char *
safe_str(const char *address) safe_str_opts(const or_options_t *options, const char *address)
{ {
tor_assert(address); tor_assert(address);
if (get_options()->SafeLogging_ != SAFELOG_SCRUB_NONE) if (!options) {
options = get_options();
}
if (options->SafeLogging_ != SAFELOG_SCRUB_NONE)
return "[scrubbed]"; return "[scrubbed]";
else else
return address; return address;
......
...@@ -143,6 +143,16 @@ MOCK_DECL(char *, ...@@ -143,6 +143,16 @@ MOCK_DECL(char *,
#define get_cachedir_fname_suffix(sub1, suffix) \ #define get_cachedir_fname_suffix(sub1, suffix) \
options_get_cachedir_fname2_suffix(get_options(), (sub1), NULL, (suffix)) options_get_cachedir_fname2_suffix(get_options(), (sub1), NULL, (suffix))
#define safe_str_client(address) \
safe_str_client_opts(NULL, address)
#define safe_str(address) \
safe_str_opts(NULL, address)
const char * safe_str_client_opts(const or_options_t *options,
const char *address);
const char * safe_str_opts(const or_options_t *options,
const char *address);
int using_default_dir_authorities(const or_options_t *options); int using_default_dir_authorities(const or_options_t *options);
int create_keys_directory(const or_options_t *options); int create_keys_directory(const or_options_t *options);
......
...@@ -1646,7 +1646,7 @@ hs_config_client_authorization(const or_options_t *options, ...@@ -1646,7 +1646,7 @@ hs_config_client_authorization(const or_options_t *options,
if (digest256map_get(auths, identity_pk.pubkey)) { if (digest256map_get(auths, identity_pk.pubkey)) {
log_warn(LD_REND, "Duplicate authorization for the same hidden " log_warn(LD_REND, "Duplicate authorization for the same hidden "
"service address %s.", "service address %s.",
safe_str_client(auth->onion_address)); safe_str_client_opts(options, auth->onion_address));
client_service_authorization_free(auth); client_service_authorization_free(auth);
goto end; goto end;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment