UNPKG

ipdb

Version:

IP lookup using IPIP.net database

95 lines (58 loc) 1.73 kB
# ipdb [![Build Status](https://travis-ci.com/metowolf/ipdb.svg?branch=master)](https://travis-ci.com/metowolf/ipdb) > IP lookup using IPIP.net database Free databases available for [download here](https://www.ipip.net/free_download/). If you need better accuracy you should consider buying [commercial subscription](https://www.ipip.net/product/ip.html#ipv4city). ## Install ``` $ npm install ipdb ``` ## Usage ```js const IPDB = require('ipdb'); const ipdb = new IPDB('./data/ipipfree.ipdb'); ipdb.find('183.62.57.1'); /* { code: 0, data: { country_name: '中国', region_name: '广东', city_name: '广州', bitmask: 18, ip: '183.62.57.1' } } */ ``` ## API ### ipdb = new IPDB(file, [options]) #### file Type: `string | Buffer` The ipdb database pathname (string) or contents (buffer). #### options Type: `object` ##### patches Type: `array` Default: `[]` See [Patches](#patches) ### ipdb.find(ip, [options]) Return a result `object` #### ip Type: `string` #### options Type: `object` ##### language Type: `string` Default: `CN` ##### patches Type: `array` Default: `[]` See [Patches](#patches) ## Patches - [@ipdb/iso3166](https://github.com/metowolf/ipdb-iso3166) - IPIP.net database patches (ISO-3166) - [@ipdb/cac](https://github.com/metowolf/ipdb-cac) - IPIP.net database patches (中国行政区划代码) - [@ipdb/range](https://github.com/metowolf/ipdb-range) - IPIP.net database patches (range of cidr) ## Related - [@ipdb/database](https://www.npmjs.com/package/@ipdb/database) - IPIP.net free database - [qqwry.ipdb](https://www.npmjs.com/package/qqwry.ipdb) - 纯真数据库 IPIP.net 格式版 ## License MIT © [metowolf](https://i-meto.com/)