Commit 0b31521f authored by Nigel Kukard's avatar Nigel Kukard
Browse files

* Better support for invalid counter limits in Accounting module

parent 832c4f82
......@@ -169,8 +169,11 @@ POLICY: foreach my $priority (sort {$a <=> $b} keys %{$sessionData->{'Policy'}}
}
# Check for violation
if (
defined($accounting->{'MessageCountLimit'}) && (
if (defined($accounting->{'MessageCountLimit'}) && $accounting->{'MessageCountLimit'} ne "") {
# If its a valid message count limit
if ($accounting->{'MessageCountLimit'} =~ /^[0-9]+$/) {
# Check if we exceeded
if ($accounting->{'MessageCountLimit'} > 0 && (
# Check current counter
(
defined($newCounters{$atrack->{'AccountingID'}}->{'MessageCount'}) &&
......@@ -178,21 +181,32 @@ POLICY: foreach my $priority (sort {$a <=> $b} keys %{$sessionData->{'Policy'}}
) ||
# Or if that doesn't match, the DB counter
$atrack->{'MessageCount'} >= $accounting->{'MessageCountLimit'}
)
) {
)) {
$hasExceeded = "Policy rejection; Message count exceeded";
}
} else {
# Bump up limit
$newCounters{$atrack->{'AccountingID'}}->{'MessageCount'}++;
$server->log(LOG_ERR,"[ACCOUNTING] The value for MessageCountLimit is invalid for accounting ID '".$accounting->{'ID'}."'");
}
}
# If we've not exceeded, check the message cumulative size
if (!$hasExceeded) {
# Bump up count
$newCounters{$atrack->{'AccountingID'}}->{'MessageCount'}++;
# Check for cumulative size violation
if (defined($accounting->{'MessageCumulativeSizeLimit'}) &&
$accounting->{'MessageCumulativeSizeLimit'} ne "") {
# If its a valid message count limit
if ($accounting->{'MessageCumulativeSizeLimit'} =~ /^[0-9]+$/) {
if ($accounting->{'MessageCumulativeSizeLimit'} > 0 &&
$atrack->{'MessageCumulativeSize'} > $accounting->{'MessageCumulativeSizeLimit'}) {
$hasExceeded = "Policy rejection; Cumulative message size exceeded";
}
} else {
$server->log(LOG_ERR,"[ACCOUNTING] The value for MessageCumulativeSizeLimit is invalid for accounting ID '".$accounting->{'ID'}."'");
}
}
}
} else {
......
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