Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isPeerMultiaddr (input) {
if (!isMultiaddr(input)) return false
if (input instanceof Buffer) {
// mafmt does not support Buffer input
input = new Multiaddr(input)
}
return mafmt.IPFS.matches(input)
}
r.once('peer', (peer) => {
const peerList = peer.multiaddrs.toArray()
expect(peerList.length).to.eq(1)
expect(mafmt.IPFS.matches(peerList[0].toString())).equals(true)
resolve()
})
})
result.forEach((item) => {
let ma = multiaddr(item.addr.toString())
if (!mafmt.IPFS.matches(ma)) {
ma = ma.encapsulate('/ipfs/' + item.peer.toB58String())
}
const addr = ma.toString()
argv.print(addr)
})
})())
'use strict'
const defaultConfig = require('../runtime/config-nodejs.js')
const isMultiaddr = require('mafmt').IPFS.matches
const callbackify = require('callbackify')
function isValidMultiaddr (ma) {
try {
return isMultiaddr(ma)
} catch (err) {
return false
}
}
function invalidMultiaddrError (ma) {
return new Error(`${ma} is not a valid Multiaddr`)
}
module.exports = function bootstrap (self) {
return {
'multiaddr-ipfs': v => mafmt.IPFS.matches(v) ? true : 'multiaddr IPFS invalid'
}