#include <jabberdlib.h>
Functions | |
| jlimit | jlimit_new (int maxt, int maxp) |
| void | jlimit_free (jlimit r) |
| int | jlimit_check (jlimit r, char *key, int points) |
Rate limits can be used to limit the number of allowed events in a given interval, e.g. the number of connects from a single IP to the server
The events can be weighted.
| int jlimit_check | ( | jlimit | r, | |
| char * | key, | |||
| int | points | |||
| ) |
update/check a key in a jlimit instance
Each jlimit instance can track many limits (that have the same setup). The limit is selected by the key, which can be an IP address.
| r | the jlimit instance | |
| key | for which key the limit should be checked | |
| points | how many points of the limit should be consumed |
References j_strcmp(), jlimit_struct::key, jlimit_struct::maxp, jlimit_struct::maxt, jlimit_struct::points, and jlimit_struct::start.
| void jlimit_free | ( | jlimit | r | ) |
free a jlimit instance
| r | the jlimit instance that should be freed |
References jlimit_struct::key, jlimit_struct::p, and pool_free().
Referenced by mio_rate().
| jlimit jlimit_new | ( | int | maxt, | |
| int | maxp | |||
| ) |
create a new instance of jlimit that is used to limit events
limit the events to maxp points per maxt seconds
| maxt | time interval (in seconds) after which the points are cleared | |
| maxp | maximum number of points available for the time interval given in maxt |
References jlimit_struct::key, jlimit_struct::maxp, jlimit_struct::maxt, jlimit_struct::p, pmalloc(), jlimit_struct::points, pool_new, and jlimit_struct::start.
Referenced by mio_rate().
1.5.5