Simple-IPInfo 0.08

Get IP/IPList Info (location, as number, etc)

Platform: CPAN

Language: Perl

License: Artistic-1.0-Perl

Repository: https://github.com/abbypan/Simple-IPInfo

View on registry: https://metacpan.org/release/Simple-IPInfo


NAME

Simple::IPInfo - Get IP/IPList Info (location, as number, etc)

给定IP列表,查对应的区域信息,或AS号

SYNOPSIS

    use Simple::IPInfo;
    use Data::Dumper;
    use utf8;

    my $rr_loc = get_ip_loc([ '202.38.64.10', '202.96.196.33' ]);
    my $rr_asn = get_ip_as([ '202.38.64.10', '202.96.196.33' ]);
    print Dumper($rr_loc, $rr_asn);

    my $r_json = get_ipinfo_io('202.38.64.10');
    print Dumper($r_json);

DESCRIPTION

    default ip as data: ftp://routeviews.org/dnszones/originas.bz2

    default ip location data: http://ip.taobao.com

    online ip api: http://ipinfo.io

TOOL

add_ip_info.pl

    perl add_ip_info.pl -f xt/02.ip.csv -d xt/02.ip.csv.log -i 0 -t loc -H 1

    f : source file 源文件
    d : dest file 目标文件
    i : ip is in cloumn x, ip在第x列
    H : skip head or not,default is 0 (not skip) 默认不跳过首行
    t : loc or as, default is loc;添加信息类型,默认是加loc信息,也可指定为as
    s : sep character, default is ',' 默认分隔符为逗号

METHOD

get_ip_loc

get ip location, with state, prov, isp

返回IP区域信息,包括国家、省份、运营商

    my $rr = get_ip_loc([ '202.38.64.10', '202.96.196.33' ]);

    # {  
    # $ip_a => { state => ... , prov => ..., isp => ... }, 
    # $ip_b => { state => ... , prov => ..., isp => ... }, 
    # }

get_ip_as

get ip as number

返回IP的AS号

    my $rr = get_ip_as([ '202.38.64.10', '202.96.196.33' ]);

    # {  
    # $ip_a => { as => ... }, 
    # $ip_b => { as => ... }, 
    # }

get_ipinfo

get_ipinfo from some csv file, see also IPInfo_LOC.csv

给定IP列表,以及csv文件,返回csv文件提供的IP信息,格式参考IPInfo_LOC.csv

    my $rr = get_ipinfo([ '202.38.64.10', '202.96.196.33' ], 
        ip_info_file => 'some_ipinfo.csv', 
        use_ip_c => 0, 
    );

get_ipc_info

get_ipc_info from ip info hash

指定ip,从已知的ip_c段hash中取出对应的信息

    my $r =  get_ipc_info('202.38.64.10', $rr);

append_table_ipinfo

add ipinfo to arrayref

    use Simple::IPInfo;
    use Data::Dumper;

    my $arr = [ [qw/202.38.64.10 xxx/], [qw/8.8.8.8 yyy/], ];

    my $r = append_table_ipinfo(
        $arr, 
        0,
        write_file => '02.read_table_ipinfo_loc.csv', 
        sep => ',', 
        charset         => 'utf8',
        return_arrayref => 1,
        ipinfo_names    => [qw/state prov isp/],
        write_head => [qw/ip some state prov isp/ ], 
    );
    print Dumper($r);

    my $asn_r = append_table_ipinfo(
        $arr, 
        0,
        write_file => '02.read_table_ipinfo_as.csv', 
        sep => ',', 
        charset         => 'utf8',
        return_arrayref => 1,
        ipinfo_file => $Simple::IPInfo::IPINFO_AS_F,
        ipinfo_names    => [qw/as/],
    );
    print Dumper($asn_r);

get_ipinfo_io

ip info is from http://ipinfo.io

get ip location, with loc, country, isp, as number

返回IP区域信息,包括地理位置、国家、运营商、AS号

    my $r = get_ipinfo_io('202.38.64.10');
    
    print Dumper($r);

ATTR

DEBUG

set $Simple::IPInfo::DEBUG = 1 for more details

XBIN

    system need install curl、bunzip2、tar

get ip as data from routeviews.org

    perl parse_ip_as.pl 

    mv originas.csv IPInfo_AS.csv

get ip loc from taobao

    1) init data dir, and null csv file

    perl init_ip_loc.pl

    2) add ask_ip_loc.pl to crontab, for example

    */5 * * * * cd ip_loc_taobao/bin && perl ask_ip_loc.pl >/dev/null 2>&1
    
    3) merge data/*.csv to ip_loc_taobao.csv , get main tidy csv

    perl merge_ip_loc.pl

    perl tidy_ip_loc.pl ip_loc_taobao.csv ip_loc_taobao.tidy.csv

    4) compare with ip_loc_old.csv

    #按inet顺序
    perl sort_ip_loc.pl ip_loc_old.csv ip_loc_old.sort.csv

    perl tidy_ip_loc.pl ip_loc_old.sort.csv ip_loc_old.tidy.csv

    perl compare_ip_loc.pl  ip_loc_old.tidy.csv ip_loc_taobao.tidy.csv  ip_loc_compare.csv

    5) fix cn ip loc, guess by same as number

    perl fix_ip_loc.pl ip_loc_compare.csv  ip_loc_fix.csv

    6) merge with fix_cn data

    perl compare_ip_loc.pl ip_loc_compare.csv ip_loc_fix.csv ip_loc.csv

    7) parse ip_loc.csv, map ipc to inet range

    perl parse_ip_loc.pl ip_loc.csv ip_loc_inet.csv

    mv ip_loc_inet.csv IPInfo_LOC.csv

    9) rename ip_loc.csv to old

    mv ip_loc.csv ip_loc_old.tidy.csv

AUTHOR

Abby Pan <abbypan@gmail.com>

thanks to Gabor Szabo <szabgab@gmail.com>


Dependencies Requirements Latest Stable Latest Release Licenses
Data-Validate-IP 0 0.27 Artistic-1.0-Perl
JSON 0 2.90 Artistic-1.0-Perl
Memoize 0 1.03 Other
SimpleR-Reshape 0 0.08 Artistic-1.0-Perl
Explore the resolved dependency tree for Simple-IPInfo 0.08
Configure Dependencies Requirements Latest Stable Latest Release Licenses
ExtUtils-MakeMaker 0 7.24 Artistic-1.0-Perl
Explore the resolved configure dependency tree for Simple-IPInfo 0.08

Releases

  • 0.08 - January 11, 2017 19:26
  • 0.07 - January 11, 2017 18:55
  • 0.06 - February 10, 2015 09:03
  • 0.05 - September 09, 2014 03:12
  • 0.04 - August 28, 2014 07:47
  • 0.03 - August 25, 2014 09:06
  • 0.02 - August 14, 2014 01:57
  • 0.01 - April 30, 2014 08:14

Project Statistics

SourceRank 7
Dependencies 4
Dependent projects 0
Dependent repositories 0
Total releases 8
Latest release
First release
Stars 0
Forks 1
Watchers 0
Contributors 3
Repo Size: 15.5 MB

Top Contributors See all

Pan Lanlan Neil Bowers Gabor Szabo

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2017-01-13 21:12:43 UTC

Login to resync this project