|
Re: [pm-h] converting IP<->hostname and UID<->username: msg#00019lang.perl.perl-mongers.houston
On Tue, 28 Mar 2006 16:01:59 -0600 (CST) Paul Archer <tigger@xxxxxx> 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 | | alan@xxxxxxxxxxxx | 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 | -----------------------------------------------------------------------
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [pm-h] [PBML] converting IP<->hostname and UID<->username, Paul Archer |
|---|---|
| Next by Date: | Re: [pm-h] converting IP<->hostname and UID<->username, Paul Archer |
| Previous by Thread: | Re: [pm-h] [PBML] converting IP<->hostname and UID<->username, Paul Archer |
| Next by Thread: | Re: [pm-h] converting IP<->hostname and UID<->username, Paul Archer |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |