Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
publicAddress: (cb) => stunServer.once('bindingResponse', (stunMsg) => {
stunServer.close()
server.close(
cb(null, Multiaddr.fromNodeAddress(stunMsg.getAttribute(STUN_ATTR_XOR_MAPPED_ADDRESS).value, 'tcp'))
)
}),
stunError: (cb) => stunServer.send(
getLocalhost(serverAddr) {
return Multiaddr.fromNodeAddress({ port: serverAddr.port, address: '127.0.0.1', family: 'IPv4' }, 'udp').encapsulate(
`/ipfs/${this.node.peerInfo.id.toB58String()}`
)
}
.map(addr =>
Multiaddr.fromNodeAddress({ port: serverAddr.port, ...addr }, 'udp').encapsulate(`/ipfs/${this.node.peerInfo.id.toB58String()}`)
)
getLocalhost(serverAddr) {
return Multiaddr.fromNodeAddress({ port: serverAddr.port, address: '::1', family: 'IPv6' }, 'udp').encapsulate(
`/ipfs/${this.node.peerInfo.id.toB58String()}`
)
}
function decode(data) {
var addr = multiaddr.fromNodeAddress(data.from, 'udp')
var peer = peerbook.getByAddress(addr)
if (!peer)
throw new Error('ipfs net pipe: no peer for udp addr ' + item.peer.id)
data.from = peer.id
return data
}
}