find-ip-location

0.0.3 • Public • Published

find-ip-location

Build Status Coverage Status NPM version Code Climate bitHound David

参考maxmind实现的纯javascript地址库;基于ipb提供的付费ip地址库实现ip地址解析,中国国内的地址精确到省市,国外的精确到国家。需要使用配套工具将提供的ip地址库文件,转换成工具需要的二进制格式文件。该地址库主要针对中国国内的ip地址解析。

Installation

$ npm install --save find-ip-location

Usage:

var ipQuery = require("find-ip-location")
var sampleFilePath = 'db path'
 
// Sync
var ipFinder = ipQuery.loadDBSync(sampleFilePath)
ipFinder.find('66.6.44.4')
 
// Async
ipQuery.loadDB(sampleFilePath, (err, ipFinder) => {
  if(err){
    console.log(err.message)
  }else{
    ipFinder.find('66.6.44.4')
  }
})

返回的参数包含:["startIP", "endIP", "code", "province", "hanCity", "city", "isoCode", 'provinceCode', 'cityCode', 'countryCode', 'country']

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i find-ip-location

Weekly Downloads

3

Version

0.0.3

License

MIT

Last publish

Collaborators

  • liuwill