Re: [exim] Need a little unix help

Top Page
Delete this message
Reply to this message
Author: Chris Lightfoot
Date:  
To: Marc Perkel
CC: exim users
Subject: Re: [exim] Need a little unix help
On Thu, Jul 20, 2006 at 04:21:03PM -0700, Marc Perkel wrote:
> Some of you I'm srue are experts at this. I can probably get something
> to work but I want to do it right. And it's fairly simple.
>
> What I want to do is create a simple client/server application where
> clients running Exim can easily report IP addresses to the server. The
> server will accept the IP addresses and execute a command to add the IP
> address to a MySQL database and increment a counter. What I'm
> specifically doing is counting spam/ham based on IP address. But - if I
> can just receive the IP address I'll figure put how to process it.
>
> I have xinentd if that maes things easy.
>
> On the client side I want to in an efficient way be able to pass a
> string containing the IP address to the server. Maybe talk to an open port?
>
> So - what's the simplest way to accomplish this?


I'd be tempted to use HTTP perl -- put in a perl startup
file containing something like,

    use LWP::Simple;
    use Digest::HMAC_SHA1 qw(hmac_sha1_hex);


    my $url = 'http://somewhere/something';
    my $secret = 'some secret value shared with the server';


    sub transmit_ip_to_server ($) {
        my $ip = shift;
        get("$url?ip=$ip;mac=" . hmac_sha1_hex($ip, $secret));
    }


and write the corresponding CGI script to check the MAC
and accept the submissions. HTTP purists will note I
should be using POST not GET and crypto purists would
probably want some kind of random padding in the protocol,
but you get the idea. Then use something like

    ${perl{transmit_ip_to_server}{$address}}


in an ACL to send the information.

--
``I had one [good seventh grade teacher]. Smart, witty, excellent
communicator, young, and beautiful. Naturally, she fell over
dead in class from a brain haemorrhage.'' (seen on the internet)