How to use the ipfs-geoip.lookupPretty function in ipfs-geoip

To help you get started, we’ve selected a few ipfs-geoip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs-shipyard / ipfs-webui / src / js / pages / connections.js View on Github external
peers.forEach((peer, i) => {
        peer.ipfs = this.props.ipfs
        peer.location = {
          formatted: ''
        }

        let id = peer.peer.toB58String()
        let location = this.state.locations[id]
        if (!location) {
          this.state.locations[id] = {}
          const addr = peer.addr.toString()
          getLocation(this.props.ipfs, [addr], (err, res) => {
            if (err) return console.error(err)
            // If we've unmounted, abort
            if (!this.mounted) return

            res = res || {}
            peer.location = res
            let locations = this.state.locations
            locations[id] = res
            peers[i] = peer
            this.setState({
              peers,
              locations,
              nonce: this.state.nonce++
            })
          })
        }
github ipfs-shipyard / ipfs-webui / src / js / pages / home.js View on Github external
this.props.ipfs.id((err, peer) => {
      if (err || !peer) return console.error(err)
      if (!this.mounted) return
      this.setState({
        node: {
          peer,
          location: {}
        }
      })
      getLocation(this.props.ipfs, peer.addresses, (err, location) => {
        if (err || !location) return console.error(err)
        if (!this.mounted) return
        this.setState({
          node: {
            peer,
            location
          }
        })
      })
    })
  }
github ipfs-shipyard / ipfs-desktop / src / utils / stats-poller.js View on Github external
_handleId (raw) {
    this.statsCache.node = raw
    this.statsCache.node.location = 'Unknown'

    lookupPretty(this.ipfs, raw.addresses, (err, location) => {
      if (err) { return }

      this.statsCache.node.location = location && location.formatted
      this.emit('change', this.statsCache)
    })
  }
github ipfs-shipyard / ipfs-desktop / src / utils / stats-poller.js View on Github external
raw.forEach((rawPeer) => {
      let peer = {
        id: rawPeer.peer.toB58String(),
        addr: rawPeer.addr.toString(),
        location: {
          formatted: 'Unknown'
        }
      }

      if (!this.locationsCache[peer.id]) {
        lookupPretty(this.ipfs, [peer.addr], (err, result) => {
          if (err) { return }
          this.locationsCache[peer.id] = result
        })
      } else {
        peer.location = this.locationsCache[peer.id]
      }

      peers.push(peer)
    })
github ipfs-shipyard / ipfs-desktop / src / init.js View on Github external
.then((peer) => {
      lookupPretty(ipfs, peer.addresses, (err, location) => {
        if (err) throw err
        statsCache.location = location && location.formatted
        mb.window.webContents.send('stats', statsCache)
      })
    })
    .catch((err) => {

ipfs-geoip

Library for ipfs geoip lookups

MIT
Latest version published 12 months ago

Package Health Score

62 / 100
Full package analysis

Popular ipfs-geoip functions