From c2871c895366f2fa285b02d51039699c0d9adabb Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 29 Jan 2017 08:44:44 +0000 Subject: [PATCH] feat: bootstrap as an option --- README.md | 1 + src/cli/commands/swarm/peers.js | 9 ++++++++- src/core/components/libp2p.js | 9 ++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4fb81385bd..8ee50b9894 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ Commands: - default repo location: `~/.jsipfs` (can be changed with env variable `IPFS_PATH`) - default swarm port: `4002` - default API port: `5002` +- default Bootstrap is off, to enable it set `IPFS_BOOTSTRAP=1` ### HTTP-API diff --git a/src/cli/commands/swarm/peers.js b/src/cli/commands/swarm/peers.js index 27d06a3d89..0d299c2c4a 100644 --- a/src/cli/commands/swarm/peers.js +++ b/src/cli/commands/swarm/peers.js @@ -2,6 +2,8 @@ const utils = require('../../utils') const debug = require('debug') +const mafmt = require('mafmt') +const multiaddr = require('multiaddr') const log = debug('cli:object') log.error = debug('cli:object:error') @@ -28,7 +30,12 @@ module.exports = { } result.forEach((item) => { - console.log(item.addr.toString()) + let ma = multiaddr(item.addr.toString()) + if (!mafmt.IPFS.matches(ma)) { + ma = ma.encapsulate('/ipfs/' + item.peer.toB58String()) + } + const addr = ma.toString() + console.log(addr) }) }) }) diff --git a/src/core/components/libp2p.js b/src/core/components/libp2p.js index 49716d89b2..a133bb91bf 100644 --- a/src/core/components/libp2p.js +++ b/src/core/components/libp2p.js @@ -6,14 +6,17 @@ const promisify = require('promisify-es6') module.exports = function libp2p (self) { return { start: promisify((callback) => { - self.config.get('Discovery.MDNS.Enabled', gotConfig) + self.config.get(gotConfig) - function gotConfig (err, enabled) { + function gotConfig (err, config) { if (err) { return callback(err) } - const options = { mdns: enabled } + const options = { + mdns: config.Discovery.MDNS.Enabled, + bootstrap: config.Bootstrap + } self._libp2pNode = new Node(self._peerInfo, undefined, options)