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

Only show connected addrs for peers in swarm.peers #960

Merged
merged 10 commits into from
Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@
"devDependencies": {
"aegir": "^11.0.2",
"buffer-loader": "0.0.1",
"chai": "^4.1.1",
"chai": "^4.1.2",
"delay": "^2.0.0",
"detect-node": "^2.0.3",
"dir-compare": "^1.4.0",
"dirty-chai": "^2.0.1",
"eslint-plugin-react": "^7.2.1",
"eslint-plugin-react": "^7.3.0",
"execa": "^0.8.0",
"expose-loader": "^0.7.3",
"form-data": "^2.2.0",
"form-data": "^2.3.1",
"gulp": "^3.9.1",
"interface-ipfs-core": "~0.30.1",
"interface-ipfs-core": "~0.31.12",
"ipfsd-ctl": "~0.21.0",
"left-pad": "^1.1.3",
"lodash": "^4.17.4",
Expand All @@ -92,8 +92,8 @@
"async": "^2.5.0",
"bl": "^1.2.1",
"boom": "^5.2.0",
"cids": "^0.5.1",
"debug": "^3.0.0",
"cids": "~0.5.1",
"debug": "^3.0.1",
"fsm-event": "^2.1.0",
"glob": "^7.1.2",
"hapi": "^16.5.2",
Expand All @@ -111,30 +111,29 @@
"is-ipfs": "^0.3.0",
"is-stream": "^1.1.0",
"joi": "^10.6.0",
"libp2p": "^0.11.0",
"libp2p": "~0.11.0",
"libp2p-floodsub": "~0.11.0",
"libp2p-kad-dht": "^0.4.1",
"libp2p-mdns": "^0.8.0",
"libp2p-multiplex": "^0.4.4",
"libp2p-railing": "^0.6.1",
"libp2p-secio": "^0.7.1",
"libp2p-swarm": "^0.31.0",
"libp2p-tcp": "^0.10.2",
"libp2p-webrtc-star": "^0.12.0",
"libp2p-websockets": "^0.10.1",
"libp2p-kad-dht": "~0.4.1",
"libp2p-mdns": "~0.8.0",
"libp2p-multiplex": "~0.4.4",
"libp2p-railing": "~0.6.1",
"libp2p-secio": "~0.7.1",
"libp2p-tcp": "~0.10.2",
"libp2p-webrtc-star": "~0.12.0",
"libp2p-websockets": "~0.10.1",
"lodash.flatmap": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.sortby": "^4.7.0",
"lodash.values": "^4.3.0",
"mafmt": "^2.1.8",
"mkdirp": "^0.5.1",
"mkdirp": "~0.5.1",
"multiaddr": "^2.3.0",
"multihashes": "~0.4.5",
"multihashes": "~0.4.8",
"once": "^1.4.0",
"path-exists": "^3.0.0",
"peer-book": "^0.5.0",
"peer-id": "^0.9.0",
"peer-info": "^0.10.0",
"peer-book": "~0.5.0",
"peer-id": "~0.9.0",
"peer-info": "~0.10.0",
"promisify-es6": "^1.0.3",
"pull-file": "^1.0.0",
"pull-paramap": "^1.2.2",
Expand All @@ -148,13 +147,13 @@
"safe-buffer": "^5.1.1",
"stream-to-pull-stream": "^1.7.2",
"tar-stream": "^1.5.4",
"temp": "^0.8.3",
"temp": "~0.8.3",
"through2": "^2.0.3",
"update-notifier": "^2.2.0",
"yargs": "8.0.2"
},
"optionalDependencies": {
"prom-client": "^10.0.2",
"prom-client": "^10.0.4",
"prometheus-gc-stats": "^0.5.0"
},
"contributors": [
Expand Down
14 changes: 4 additions & 10 deletions src/core/components/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const multiaddr = require('multiaddr')
const promisify = require('promisify-es6')
const flatMap = require('lodash.flatmap')
const values = require('lodash.values')

const OFFLINE_ERROR = require('../utils').OFFLINE_ERROR
Expand All @@ -24,24 +23,19 @@ module.exports = function swarm (self) {
// we currently don't have this information

const peers = values(self._peerInfoBook.getAll())
.filter((peer) => peer.isConnected())

const peerList = flatMap(peers, (peer) => {
return peer.multiaddrs.toArray().map((addr) => {
.map((peer) => {
const connectedAddr = peer.isConnected()
const res = {
addr: addr,
addr: connectedAddr,
peer: peer
}

if (verbose) {
res.latency = 'unknown'
}

return res
})
})

callback(null, peerList)
callback(null, peers)
}),

// all the addrs we know
Expand Down
6 changes: 1 addition & 5 deletions test/cli/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,22 @@ describe('bootstrap', () => runOnAndOff((thing) => {

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'
'/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3'
]

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/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD'
]

Expand Down
6 changes: 1 addition & 5 deletions test/core/bootstrap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,22 @@ 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'
'/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3'
]

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'
]

Expand Down
5 changes: 4 additions & 1 deletion test/test-data/otherconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
"RecordLifetime": "",
"ResolveCacheSize": 128
},
"Bootstrap": ["/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"],
"Bootstrap": [
"/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"],
"Tour": {
"Last": ""
},
Expand Down
14 changes: 6 additions & 8 deletions test/utils/ipfs-factory-daemon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class Factory {
}

/* yields a new started node */
spawnNode (repoPath, config, callback) {
spawnNode (repoPath, suppliedConfig, callback) {
if (typeof repoPath === 'function') {
callback = repoPath
repoPath = undefined
}
if (typeof config === 'function') {
callback = config
config = undefined
if (typeof suppliedConfig === 'function') {
callback = suppliedConfig
suppliedConfig = undefined
}

repoPath = repoPath ||
Expand All @@ -32,15 +32,13 @@ class Factory {

let daemon
let ctl
let config

series([
(cb) => {
// prepare config for node
if (config) {
return cb()
}

config = JSON.parse(JSON.stringify(defaultConfig))
config = Object.assign({}, defaultConfig, config || {})

PeerId.create({ bits: 1024 }, (err, id) => {
if (err) {
Expand Down