From: Eoin Kelly (kellyep at domain joy.ucc.ie)
Date: Mon 23 Sep 2002 - 12:48:03 IST
On Mon, Sep 23, 2002 at 10:57:39AM +0100, Vincent Cunniffe wrote:
>Valid : ... Login user=xxx host=blah.domain.com [IP]
>Invalid : ... Login user=xxx host=[IP]
>
Hi,
the following should work (assuming log lines that look similar to
my $validLogLine = "ipop2d[33]: Login user=xxx host=blah.domain.com 123.123.321.123";
my $invalidLogLine = "ipop2d[33]: Login user=xxx host=123.123.321.123";
HTH
/Eoin/
=========================================================
sub scanaddr ($) {
my $s = $_[0];
my at domain paddrs; # Packed IP addresses.
my at domain addrs; # ASCII addresses.
my $junk;
if ($s =~ m/i(pop2|pop3|map)d\[[0-9]+\]: (Login|Authenticated) user=/) {
$s =~ /.*host=(\S+)\s*(\S*).*/;
my($try1,$try2) = ($1,$2);
if ( $try1 =~ /^\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}$/ ) {
$s = $try1;
}
elsif($try2 =~ /^\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}$/ ) {
$s = $try2;
}
else {
warn "Failed to parse IP address from '$s'";
}
($junk, $junk, $junk, $junk, at domain paddrs) = gethostbyname($s);
while ( at domain paddrs) {
push( at domain addrs, join('.', unpack('C4', shift( at domain paddrs))));
}
return at domain addrs;
}
return ();
}
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:19:00 GMT