Download Latest Version milter_rate_limit-20160201-src.tar.gz (41.0 kB)
Email in envelope

Get an email when there's a new version of Milter rate limiter

Home
Name Modified Size InfoDownloads / Week
README.txt 2016-02-01 3.2 kB
milter_rate_limit-20160201-src.tar.gz 2016-02-01 41.0 kB
milter_rate_limit-20151009-src.tar.gz 2015-10-09 40.0 kB
milter_rate_limit-20150817-src.tar.gz 2015-08-17 40.3 kB
milter_rate_limit-20150710-src.tar.gz 2015-07-10 39.6 kB
milter_rate_limit-20140710-src.tar.gz 2014-07-10 39.8 kB
milter_rate_limit-20140703-src.tar.gz 2014-07-03 37.4 kB
milter_rate_limit-20130121-src.tar.gz 2013-01-21 34.0 kB
Totals: 8 Items   275.2 kB 0
Milter rate limiter.
--------------------

This is a milter filter for rate-limiting of outgoing mail per user account.

Data is kept in a memory db.

A list of domain(s) to handle should be defined (domain.domains).
Normal user accounts should be available via LDAP for these domains.
There is a lax mode where only the last part of the domain need to match.
An "always pass" list is also available.

There are two background threads. One purges the database (removes all entries with zeroed step and count).
The other background thread updates step and counter and unblocks blocked users.


Working principle:

Accounting is based per user (uid). 
Sent email messages has a cost associated of one second per recipient (may be increased using parameter counter.cost_per_rcpt).
The accumulated cost is reduced as time passes (one per second).

The cost limit (600 by default) is divided into steps defined by a blocking_limit (3 by default)).
A counter is updated for each step (default -> 200) passed.
When a user counter reaches the warning_limit (by default set to 1) a warning will be logged.
If a user counter reaches blocking_limit the user will become blocked (further messages will be rejected).
A special "follow this user"-mode is activated when a user has a negative cost setting (-1 is reserved for "unlimited"). 
The user will in this case not be blocked, logging etc will however occur as if blocked.

The update thread executes periodically. The "cost" and "counter" decreases and blocked users will be unblocked when the "counter" becomes zero.

Senders not matching any of your domains will always either be passed, always rejected, or added to the db similar to a normal uid user, 
possibly with a lower cost threshold (counter.unsolicited_cost). This behavior is configured via "on domain mismatch".

Senders not found via LDAP in your domains (missing uid) will also either be passed, rejected, or added to the db, similar to the above.
This behavior is configured via "on uid not found".

Each user may have an individual cost limit (an LDAP attribute) that is used instead of the default cost value.
A user with a cost value of "-1" does not have any outgoing e-mail limit.

Special users may be added. These are either non LDAP uids in your own domain(s) or other explicit external "user@domain".
The reason to add these users here is to be able to individually configure the cost to a specific value (or -1 for unlimited).
Special users are typically "postmaster", "root", "noreply", etc.

Interactive access to the internal database is available if fhe command line option "-n <port>" is specifed.
Use telnet to connect (the port is only available locally on the machine). Commands: "help", "list", "unblock", "purge" and "add".

---

Dependencies:
- libmilter	ftp://ftp.sendmail.org/pub/sendmail (libmilter is included in sendmail)
- libconfig	http://www.hyperrealm.com/libconfig (version >= 1.4)
- openldap	http://www.openldap.org/
- khash.h	https://github.com/attractivechaos/klib/khash.h (is included in the milter-rate-limit tar-file)

---

    Hakan.Lennestal@ltu.se
   
    Luleå University of Technology 
    Håkan Lennestål
    SE-971 87 LULEÅ Sweden

Source: README.txt, updated 2016-02-01