Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about programming (old posts, page 39)

Coming ideas

Nowadays, the very little time I have for personal projects is spent doing things like fixing little things and adding little features to BartleBlog 1 and thinking how I could use GLE and mako templates to create a cool nerdy tool to create charts.

However, I will be having a little time for personal projects in a couple of weeks, and having stumbled onto chipmunk today really got me thinking.

It's a seriously nifty 2D physics library. Consider this demo video:

Now, what could possibly be done with it... I need to really think.

1

What I use to post this.

Rater progresses (slowly)

I am hacking a bit on rater my daemon/client to see if things are happening more often than they should (in other words, generic rate limiting).

I had to take a few days off, since my brother got married and we all went back to Santa Fe for that and a weekend, and then everyone else has sore throats and I am the only one healthy.

But hey, it works well enough already:

  • The simplistic protocol is done

  • The server works

    • It can take hours of gibberish without problems.

    • It can take hours of valid input without problems.

    • It does what it's supposed to do.

  • It's staying below 300SLOC, which was my goal.

Missing stuff:

  • Valgrind it.

  • Client library.

  • Generic CLI client.

  • A qmail-spp plugin that uses it.

And then, I can forget all about it.

Snow and rates

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).