aboutsummaryrefslogtreecommitdiff
path: root/src/feature/dirclient/dirclient.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-02-20 12:26:32 -0500
committerNick Mathewson <nickm@torproject.org>2020-02-20 12:26:32 -0500
commitce9eeefbcc7c87c7608612605fa325d712c2c944 (patch)
tree37e1de9bda5ba63928a91441f95921887eef7f35 /src/feature/dirclient/dirclient.c
parent93af83e16a620a8e8d9972f65b724e4e3a520434 (diff)
downloadtor-ce9eeefbcc7c87c7608612605fa325d712c2c944.tar.gz
tor-ce9eeefbcc7c87c7608612605fa325d712c2c944.zip
Make direclient_dump_total_dls() respect SafeLogging and pass tests.
Don't dump totals with anonymous purposes. Additionally, don't dump headers that have nothing underneath them.
Diffstat (limited to 'src/feature/dirclient/dirclient.c')
-rw-r--r--src/feature/dirclient/dirclient.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/feature/dirclient/dirclient.c b/src/feature/dirclient/dirclient.c
index 7c7057b102..ecedbddf44 100644
--- a/src/feature/dirclient/dirclient.c
+++ b/src/feature/dirclient/dirclient.c
@@ -1981,19 +1981,22 @@ static uint64_t total_dl[DIR_PURPOSE_MAX_][2];
void
dirclient_dump_total_dls(void)
{
- log_notice(LD_NET,
- "While bootstrapping, fetched this many bytes: ");
- for (int i=0; i < DIR_PURPOSE_MAX_; ++i) {
- uint64_t n = total_dl[i][0];
- if (n) {
- log_notice(LD_NET, " %zu (%s)", n, dir_conn_purpose_to_string(i));
- }
- }
- log_notice(LD_NET,
- "While not bootsrapping, fetched this many bytes: ");
- for (int i=0; i < DIR_PURPOSE_MAX_; ++i) {
- uint64_t n = total_dl[i][1];
- if (n) {
+ const or_options_t *options = get_options();
+ for (int bootstrapped = 0; bootstrapped < 2; ++bootstrapped) {
+ bool first_time = true;
+ for (int i=0; i < DIR_PURPOSE_MAX_; ++i) {
+ uint64_t n = total_dl[i][0];
+ if (n == 0)
+ continue;
+ if (options->SafeLogging_ != SAFELOG_SCRUB_NONE &&
+ purpose_needs_anonymity(i, ROUTER_PURPOSE_GENERAL, NULL))
+ continue;
+ if (first_time) {
+ log_notice(LD_NET,
+ "While %sbootstrapping, fetched this many bytes: ",
+ bootstrapped?"not ":"");
+ first_time = false;
+ }
log_notice(LD_NET, " %zu (%s)", n, dir_conn_purpose_to_string(i));
}
}