Net-SPAMerLookup

 view release on metacpan or  search on metacpan

lib/Net/SPAMerLookup.pm  view on Meta::CPAN

		  };
	  };
	eval {
		local $SIG{ALRM}= sub { die 'Timeout' };
		alarm $timeout;
		for ($is_ip ? @RBL_IP: @RBL_URI) {
			my $hit= $check->($_) || next;
			alarm 0;
			return { %$hit, RBL=> $_ };
		}
		alarm 0;
	  };
	if (my $error= $@) { $self->is_error($error) }
	0;
}
sub is_error {
	my $self= shift;
	return $self->[1] unless @_;
	$self->[1]= shift;
	0;
}
sub is_spamer {
	my $self= shift;
	for (@_) { if (my $target= $self->check_rbl($_)) { return $target } }
	0;
}

1;

__END__

=head1 NAME

Net::SPAMerLookup - Perl module to judge SPAMer.

=head1 SYNOPSIS

  use Net::SPAMerLookup {
    IP => [qw/ niku.2ch.net all.rbl.jp list.dsbl.org /],
    URI=> [qw/ url.rbl.jp notop.rbl.jp all.rbl.jp /],
    };
  
  my $spam= Net::SPAMerLookup->new;
  if ($spam->check_rbl($TARGET)) {
  	print "It is SPAMer.";
  } else {
  	print "There is no problem.";
  }
  
  # Whether SPAMer is contained in two or more objects is judged.
  if (my $spamer= $spam->is_spamer(@TARGET)) {
  	print "It is SPAMer.";
  } else {
  	print "There is no problem.";
  }

=head1 DESCRIPTION

SPAMer is judged by using RBL.

Please set HTTP_PROXY of the environment variable if you use Proxy.

see L<Net::Domain::TldMozilla>.

=head1 SETTING RBL USED

When passing it to the start option.

  use Net::SPAMerLookup qw/ all.rbl.jp .....  /;

When doing by the import method.

  require Net::SPAMerLookup;
  Net::SPAMerLookup->import(qw/ all.rbl.jp ..... /);

=head1 METHODS

=head2 new

Constructor.

  my $spam= Net::SPAMerLookup;

=head2 check_rbl ([ FQDN or IP_ADDR or URL ])

'Host domain name', 'IP address', 'Mail address', and 'URL' can be passed to the argument.

HASH including information is returned when closing in passed value RBL.

0 is returned when not closing.

Following information enters for HASH that was able to be received.

=over 4

=item * RBL

RBL that returns the result enters.

=item * name or address

The value enters 'Address' at 'Name' and "IP address" when the object is "Host domain name" form.

=item * result

Information returned from RBL enters by the ARRAY reference.

=back 

  if (my $result= $spam->check_rbl('samp-host-desuka.com')) {
    print <<END_INFO;
    It is SPAMer.
  
  RBL-Server: $result->{RBL}
  
  @{[ $result->{name} ? qq{Name: $result->{name}}: qq{Address: $result->{address}} ]}
  
  @{[ join "\n", @{$result->{result}} ]}
  
  END_INFO
  } else {



( run in 1.932 second using v1.01-cache-2.11-cpan-71847e10f99 )