On Tue, 28 Mar 2006 16:01:59 -0600 (CST)
Paul Archer <[EMAIL PROTECTED]> wrote:

> Can anyone suggest modules that can convert IP addresses to and from 
> hostnames, and UIDs to and from usernames? I've searched CPAN, but I 
> didn't come up with anything.
> Or should I just call 'getent'? (That works for UID<->username, but not for 
> IP addresses not in the host file...)
> 

Not an easy problem. I've written a lot of anti-spam software, and have beaten
on this problem several times. Here is a snippet of code that does a pretty
good job...

        $host = `/usr/bin/host $ip`;
        my $foo = (split(/\s+/, $host))[4];
    if ($host =~ /not found/ || length($foo)<4) {
            $host = `zcw -h $ip | grep Abuse`;
    }
    if (length $host < 1) {$host = 'UNK';}
    if ($host eq 'reached') {$host = 'UNK';}
        $host = (split(/\s+/,$host))[-1];
        $host = (split(/@/,$host))[-1];

zcw is a nice bit of code I got from www.cyberabuse.org.

Of course, before I even go through these gyrations, I have a simple 
database that I keep every IP address I have received e-mail from,
the domain, and a counter, and I check that first.


-- 
-----------------------------------------------------------------------
| Alan K. Jackson            | To see a World in a Grain of Sand      |
| [EMAIL PROTECTED]          | And a Heaven in a Wild Flower,         |
| www.ajackson.org           | Hold Infinity in the palm of your hand |
| Houston, Texas             | And Eternity in an hour. - Blake       |
-----------------------------------------------------------------------
_______________________________________________
Houston mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/houston

Reply via email to