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