aboutsummaryrefslogtreecommitdiff
path: root/src/or/status.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-09-23 08:34:22 -0400
committerNick Mathewson <nickm@torproject.org>2014-09-29 09:05:11 -0400
commit8527a2996675d9502551ccdd4224036a45aae47b (patch)
tree9b2ab6a02949da52b42b5b1b1b4cd7a29465e778 /src/or/status.c
parente6150c7fc079d7841bedd0df838b29aef0f497d7 (diff)
downloadtor-8527a2996675d9502551ccdd4224036a45aae47b.tar.gz
tor-8527a2996675d9502551ccdd4224036a45aae47b.zip
Add an "AccountingRule" feature to permit limiting bw usage by read+write
Patch from "chobe". Closes ticket 961.
Diffstat (limited to 'src/or/status.c')
-rw-r--r--src/or/status.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/or/status.c b/src/or/status.c
index c4156d0cc3..4158df5ad5 100644
--- a/src/or/status.c
+++ b/src/or/status.c
@@ -145,10 +145,15 @@ log_accounting(const time_t now, const or_options_t *options)
or_state_t *state = get_or_state();
char *acc_rcvd = bytes_to_usage(state->AccountingBytesReadInInterval);
char *acc_sent = bytes_to_usage(state->AccountingBytesWrittenInInterval);
- char *acc_max = bytes_to_usage(options->AccountingMax);
+ const char *acc_rule = options->AccountingRule;
+ uint64_t acc_bytes = options->AccountingMax;
+ char *acc_max;
time_t interval_end = accounting_get_end_time();
char end_buf[ISO_TIME_LEN + 1];
char *remaining = NULL;
+ if (strcmp(acc_rule, "sum") == 0)
+ acc_bytes *= 2;
+ acc_max = bytes_to_usage(acc_bytes);
format_local_iso_time(end_buf, interval_end);
remaining = secs_to_uptime(interval_end - now);