The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sendmail::AbuseIPDB - API access for IP address abuse database

SYNOPSIS

    use Sendmail::AbuseIPDB;

    my $db = Sendmail::AbuseIPDB->new(Key => '** your API key here **');

    my $ip = '31.210.35.146';                       # IP of sender
    my @all_data = $db->get( $ip );

    foreach my $d ( @all_data )
    {
        foreach my $c ( @{$d->{category}} )
        {
            print "DATE:$d->{created}   CATEGORY:" . $db->catg( $c ) . "\n";
        }
    }

DESCRIPTION

    Convenient toolbox for API access to https://www.abuseipdb.com/

    Potentially for other sites with compatible API if you want to change the BaseURL.

METHODS

new( Key => $key, ... )

    Additional parameters are: BaseURL, Days, Debug

get( $ip )

    Do a query to check an IP address. Returns array of hash references, looking similar to this:

        {
            'created' => 'Sun, 17 Sep 2017 04:53:45 +0000',
            'country' => 'Turkey',
            'isoCode' => 'TR',
            'ip' => '31.210.35.146',
            'category' => [
                            14
                          ]
        }

catg( $number )

    Convert the category from integer to printable string.

filter( $category, @data )

    Return an array of those members in @data that match the given category.
    The format of @data is same as the return array from get() so see above.
    The $category can be either a number, or a printable string.

report( $ip, $comment, @category_list )

    Report an abusive IP address back to the database.
    The comment can be "" empty string or any other brief comment to explain why
    you believe this IP has done something wrong.
    One or more categories must be included, these can be numbers or printable
    string categories. e.g. :

    $db->report( '111.119.210.10', 'Very annoying IP address', 'Brute-Force', 'Port Scan' );

SEE ALSO

    https://www.abuseipdb.com/api.html

    https://www.abuseipdb.com/categories

    Sendmail::PMilter

    Example program abuseipdb_milter.pl for a simple way to block suspicious senders.

AUTHOR

    <ttndy@cpan.org>

COPYRIGHT AND LICENSE

    This library is free software; you can redistribute it and/or modify
    it under the same terms as Perl itself, either Perl version 5.10.1 or,
    at your option, any later version of Perl 5 you may have available.