• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ipfs-shipyard/ipfs-geoip: geoip lookup over ipfs

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ipfs-shipyard/ipfs-geoip

开源软件地址:

https://github.com/ipfs-shipyard/ipfs-geoip

开源编程语言:

JavaScript 100.0%

开源软件介绍:

IPFS GeoIP

standard-readme compliant Dependency Status Travis CI Coverage Status

geoip lookup over ipfs

Install

NPM

npm install --save ipfs-geoip

CDN

Instead of a local installation (and browserification) you may request a remote copy from jsDelivr:

<!-- loading the minified version using jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js"></script>

When using prebuilt bundle from CDN, ipfs-geoip will be exposed under window.IpfsGeoip

Usage

const geoip = require('ipfs-geoip')
const ipfs = require('ipfs-http-client')()

const exampleIp = '66.6.44.4'

try {
  const result = await geoip.lookup(ipfs, exampleIp)
  console.log('Result: ', result)
} catch (err) {
  console.log('Error: ' + err)
}

try {
  const result = await geoip.lookupPretty(ipfs, '/ip4/' + exampleIp)
  console.log('Pretty result: %s', result.formatted)
} catch (err) {
  console.log('Error: ' + err)
}

API

lookup(ipfs, ip)

Returns a promise that resolves to an object of the form

{
  "country_code": "US",
  "country_name": "USA",
  "region_code": "CA",
  "city": "Mountain View",
  "postal_code": "94040",
  "latitude": 37.3860,
  "longitude": -122.0838,
  "planet": "Earth"
}

lookupPretty(ipfs, multiaddrs)

Provides the same results as lookup with the addition of a formatted property that looks like this: Mountain View, CA, United States, Earth.

b-tree

The utility geoip-gen reads csv files provided from GeoLite, and turns them into a 32-way branching b-tree, which is stored as ipfs json objects.


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap