Monday was a very special day:
Holiday (Independence day)
Anniversary (3 years as Rosario's boyfriend)
The first snowfall in Buenos Aires in 89 years.
Besides that, this week my brother is getting married so the whole family (including 2.5 month-old JF) is leaving for my ancestral lands tomorrow.
And I started a new small project, whcih should be finished soon.
This is something that seems useful to me in the context of mail servers, but maybe it will also find its uses elsewhere.
I call it rater, and it tells you if things are happening faster than a specific rate.
For example, I intend to use it to figure out if a specific IP is connecting to a server more than X times every Y seconds, or if a user is sending more than Z emails every T minutes.
The only thing I found for this is relayd, which is old, unmaintained and whose site has vanished.
The config file is something like this (thanks to libconfig):
limits : {
user: (
("rosario",90,20),
("ralsina",90,10),
("*",2,10)
);
ip: (
("10.0.0.*",90 , 20),
("10.0.1.*",90 , 20),
("*",2 , 10)
);
};
You can define as many classes of limits as you want (that would be ip and user in this example) and as many limit keys as you want, that will be matched using something like fnmatch.
I am using an in-memory SQLite DB for the accounting, and
an interesting library called libut for the sockets, logging, and event loop.
This library has a very interesting feature: your app gets an administrative interface for free!
[ralsina@monty rater]$ telnet localhost 4445
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
libut control port interpreter
Type 'help' for command list.
help
command description
----------------- -------------------------------------
* mem - memory pool usage summary
* var - Display or set config variables
* log - Change log file or verbosity
fds - list selected file descriptors
tmr - show pending timers
uptime - show uptime
* prf - Performance/profiling stats
* cops - List coprocesses
help - view command help
exit - close connection
Commands preceded by * have detailed help. Use help <command>.
Ok
var
name description value
--------------------- ------------------------------ --------------------
*ut_log_level log level Debugk
*ut_log_file log file /dev/stdout
*ut_jobname job name job1
*ut_control_port control port IP/port 127.0.0.1:4445
*ut_basedir shl base directory /mnt/centos/home/ralsina/Desktop/proyectos/rater
Variables prefixed with '*' can be changed.
Ok
var ut_log_level Debug
Ok
var
name description value
--------------------- ------------------------------ --------------------
*ut_log_level log level Debug
*ut_log_file log file /dev/stdout
*ut_jobname job name job1
*ut_control_port control port IP/port 127.0.0.1:4445
*ut_basedir shl base directory /mnt/centos/home/ralsina/Desktop/proyectos/rater
Variables prefixed with '*' can be changed.
Ok
Pretty neat.
Beyond this, there will be a small client-side library that hides all the network stuff behind a couple of blocking calls (or you can do your own because the protocol is silly simple).