Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs/js-ipfs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f404a8fbad70
Choose a base ref
...
head repository: ipfs/js-ipfs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 467ef34e7328
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Jan 11, 2016

  1. add bootstrap list to cli

    daviddias committed Jan 11, 2016
    4
    Copy the full SHA
    ef701dc View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    467ef34 View commit details
20 changes: 20 additions & 0 deletions src/cli/commands/bootstrap/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const Command = require('ronin').Command
const IPFS = require('../../../ipfs-core')
const debug = require('debug')
const log = debug('cli:version')
log.error = debug('cli:version:error')

module.exports = Command.extend({
desc: 'Show peers in the bootstrap list',

options: {},

run: (multiaddr) => {
var node = new IPFS()
node.bootstrap.add(multiaddr, (err, list) => {
if (err) { return log.error(err) }
})
}
})
21 changes: 21 additions & 0 deletions src/cli/commands/bootstrap/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict'

const Command = require('ronin').Command
const IPFS = require('../../../ipfs-core')
const debug = require('debug')
const log = debug('cli:version')
log.error = debug('cli:version:error')

module.exports = Command.extend({
desc: 'Show peers in the bootstrap list',

options: {},

run: (name) => {
var node = new IPFS()
node.bootstrap.list((err, list) => {
if (err) { return log.error(err) }
list.forEach(node => { console.log(node) })
})
}
})
20 changes: 20 additions & 0 deletions src/cli/commands/bootstrap/rm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const Command = require('ronin').Command
const IPFS = require('../../../ipfs-core')
const debug = require('debug')
const log = debug('cli:version')
log.error = debug('cli:version:error')

module.exports = Command.extend({
desc: 'Show peers in the bootstrap list',

options: {},

run: (multiaddr) => {
var node = new IPFS()
node.bootstrap.rm(multiaddr, (err, list) => {
if (err) { return log.error(err) }
})
}
})
22 changes: 22 additions & 0 deletions src/http-api/routes/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'

const server = require('./../index.js').server
const resources = require('./../resources')

server.route({
method: 'GET',
path: '/api/v0/bootstrap',
handler: resources.version.list
})

server.route({
method: 'POST',
path: '/api/v0/boostrap',
handler: resources.version.add
})

server.route({
method: 'DELETE',
path: '/api/v0/boostrap',
handler: resources.version.add
})
1 change: 1 addition & 0 deletions src/ipfs-core/index.js
Original file line number Diff line number Diff line change
@@ -90,6 +90,7 @@ function IPFS () {
config.Bootstrap.push(multiaddr)
repo.config.set(config, err => {
if (err) { return callback(err) }

callback()
})
})
75 changes: 75 additions & 0 deletions tests/test-cli-offline/test-bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* globals describe, it */

'use strict'

const expect = require('chai').expect
const nexpect = require('nexpect')

describe('bootstrap', () => {
const defaultList = [
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
'/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
'/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
'/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
'/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
'/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
'/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
'/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
'/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx'
]

const updatedList = [
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
'/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z',
'/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
'/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm',
'/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
'/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64',
'/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd',
'/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3',
'/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx',
'/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT'
]

it('list the bootstrap nodes', done => {
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'list'])
.run((err, stdout, exitcode) => {
expect(stdout).to.deep.equal(defaultList)
expect(err).to.not.exist
expect(exitcode).to.equal(0)
done()
})
})

it('add another bootstrap node', done => {
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'add', '/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT'])
.run((err, stdout, exitcode) => {
expect(err).to.not.exist
expect(exitcode).to.equal(0)

nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'list'])
.run((err, stdout, exitcode) => {
expect(stdout).to.deep.equal(updatedList)
expect(err).to.not.exist
expect(exitcode).to.equal(0)
done()
})
})
})

it('rm a bootstrap node', done => {
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'rm', '/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT'])
.run((err, stdout, exitcode) => {
expect(err).to.not.exist
expect(exitcode).to.equal(0)

nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'bootstrap', 'list'])
.run((err, stdout, exitcode) => {
expect(stdout).to.deep.equal(defaultList)
expect(err).to.not.exist
expect(exitcode).to.equal(0)
done()
})
})
})
})