aboutsummaryrefslogtreecommitdiff
path: root/mflib
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-05-03 13:16:34 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-05-03 13:16:34 +0300
commit9503ac3090f1013ab501e863d56277cccf301a86 (patch)
tree9d1f46fb3f3657953c34f66092629454b47f9c1f /mflib
parent4f617bee9e4bba6753bf6b88f693eb45df19a055 (diff)
downloadmailfromd-9503ac3090f1013ab501e863d56277cccf301a86.tar.gz
mailfromd-9503ac3090f1013ab501e863d56277cccf301a86.tar.bz2
Improve the rate function.
* mfd/bi_other.m4 (rate): Add second optional parameter: a threshold. * mfd/mailfromd.h (get_rate): Change prototype. * mfd/rate.c (get_rate): Take two more parameters: threshold and interval. Return rate as long. Do not increment the hit counters if the observed rate is higher than the threshold. Expire the record if no mails were sent during a time longer than `interval' seconds. * mflib/rateok.mf: New file. * mflib/Makefile.am (inc_DATA): Add rateok. * NEWS: Update
Diffstat (limited to 'mflib')
-rw-r--r--mflib/Makefile.am1
-rw-r--r--mflib/rateok.mf24
2 files changed, 25 insertions, 0 deletions
diff --git a/mflib/Makefile.am b/mflib/Makefile.am
index b963b414..8afe000f 100644
--- a/mflib/Makefile.am
+++ b/mflib/Makefile.am
@@ -23,6 +23,7 @@ inc_DATA =\
match_cidr.mf\
match_dnsbl.mf\
match_rhsbl.mf\
+ rateok.mf\
revip.mf\
sa.mf\
safedb.mf\
diff --git a/mflib/rateok.mf b/mflib/rateok.mf
new file mode 100644
index 00000000..7066eeb7
--- /dev/null
+++ b/mflib/rateok.mf
@@ -0,0 +1,24 @@
+/* Higher-level interface to the rate function.
+ Copyright (C) 2009 Sergey Poznyakoff
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+func rateok(string key, number timespan, number threshold; number mincnt)
+ returns number
+do
+ if $# > @mincnt
+ set mincnt 4
+ fi
+ return rate(%key, %timespan, %mincnt, %threshold) <= %threshold
+done

Return to:

Send suggestions and report system problems to the System administrator.