| 1 | package Mail::Maps::Lookup; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $LIBRARY); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use Exporter (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | @ISA = qw(Exporter); | |||||||||
| 9 | 1 | @EXPORT_OK = qw(host activation_code ip_address); | |||||||||
| 10 | |||||||||||
| 11 | 1 | $VERSION = '0.02'; | |||||||||
| 12 | 1 | $LIBRARY = __PACKAGE__; | |||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | use Net::DNS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 1 | $|=1; | |||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 19 | 1 | my $class = shift; | |||||||||
| 20 | 1 | my $self = bless {}, $class; | |||||||||
| 21 | 1 | return $self->init(@_); | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 1 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 25 | 1 | my $self = shift; | |||||||||
| 26 | 1 | my %args = @_; | |||||||||
| 27 | |||||||||||
| 28 | 1 | map($self->{$_}=$args{$_}, keys %args); | |||||||||
| 29 | |||||||||||
| 30 | 1 | return $self; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 1 | ▶ | sub lookup { | ||||||||
|
Subroutine
lookup: called CC=8 SCAR=31.4
Pod
documented
| |||||||||||
| 34 | 1 | my $self = shift; | |||||||||
| 35 | |||||||||||
| 36 | 1 | my $host = $self->{host}; | |||||||||
| 37 | 1 | my $activation_code = $self->{activation_code}; | |||||||||
| 38 | 1 | my $ip_address = $self->{ip_address}; | |||||||||
| 39 | |||||||||||
| 40 | 1 | ▶ | $host = $host ? $host : "r.mail-abuse.com"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | |||||||||||
| 42 | 1 | my $reverse_ip_address = reverse_ip($ip_address); | |||||||||
| 43 | 1 | my $address = "0.0.0.0.$activation_code.r.mail-abuse.com."; | |||||||||
| 44 | |||||||||||
| 45 | 1 | my $res = Net::DNS::Resolver->new; | |||||||||
| 46 | 1 | my $query = $res->search("$address",'A'); | |||||||||
| 47 | |||||||||||
| 48 | 1 | ▶ | if ($query){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | ▶ | if ($res->errorstring =~ /NOERROR/){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | my $address = "$reverse_ip_address.$activation_code.$host."; | |||||||||
| 51 | 0 | my $res = Net::DNS::Resolver->new; | |||||||||
| 52 | 0 | my $query = $res->search("$address",'A'); | |||||||||
| 53 | 0 | ▶ | if ($res->errorstring =~ /NOERROR/){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | foreach my $rr ($query->answer){ | |||||||||
| 55 | 0 | ▶ | if ($rr->type eq "A"){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 0 | $res = "address"; | |||||||||
| 57 | 0 | ▶ | if ($rr->$res){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | # listed | ||||||||||
| 59 | 0 | return 1; | |||||||||
| 60 | } | ||||||||||
| 61 | } | ||||||||||
| 62 | } | ||||||||||
| 63 | } else{ | ||||||||||
| 64 | # not listed | ||||||||||
| 65 | 0 | return 0; | |||||||||
| 66 | } | ||||||||||
| 67 | } | ||||||||||
| 68 | } else{ | ||||||||||
| 69 | # unable to connect to maps server or invalid activation code | ||||||||||
| 70 | 1 | return 2; | |||||||||
| 71 | } | ||||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 1 | ▶ | sub reverse_ip { | ||||||||
|
Subroutine
reverse_ip: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 75 | 1 | my $ip = shift; | |||||||||
| 76 | 1 | my @ad = split ('\.', $ip); | |||||||||
| 77 | 1 | return join('.', reverse(@ad)); | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 1 | 1; | |||||||||
| 81 | __END__ | ||||||||||