File: lookup-ip-address

package info (click to toggle)
libmaxmind-db-reader-perl 1.000014-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,040 kB
  • sloc: perl: 1,668; makefile: 10
file content (29 lines) | stat: -rwxr-xr-x 452 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env perl

use strict;
use warnings;

use Data::Printer;
use Getopt::Long;
use MaxMind::DB::Reader;

sub main {
    my ( $file, $ip );
    GetOptions(
        'file:s' => \$file,
        'ip:s'   => \$ip,
    );

    my $reader = MaxMind::DB::Reader->new( file => $file );
    my $record = $reader->record_for_address($ip);

    if ($record) {
        p($record);
    }
    else {
        print "No record found for $ip\n";
    }
}

main();