From 8ed1a6da4482f931691961c7267cb937e448e009 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 11 Sep 2019 13:12:19 +0200 Subject: [PATCH] fix: allow scenario when all ws-stars are offline ws-star is optional, should not break boot process --- .../src/lib/ipfs-client/embedded-chromesockets/config.js | 6 +++--- .../src/lib/ipfs-client/embedded-chromesockets/libp2p.js | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/add-on/src/lib/ipfs-client/embedded-chromesockets/config.js b/add-on/src/lib/ipfs-client/embedded-chromesockets/config.js index 1c5ac020b..180f2207c 100644 --- a/add-on/src/lib/ipfs-client/embedded-chromesockets/config.js +++ b/add-on/src/lib/ipfs-client/embedded-chromesockets/config.js @@ -23,9 +23,9 @@ const chromeSocketsOpts = { */ Swarm: [ // TODO: listening on TCP (override IP and port at runtime in buildConfig()?) - '/ip4/0.0.0.0/tcp/0' - // TODO: disabled -star signaling: it makes a backup non-LAN peer discovery, but break the boot if server is down - // '/dns4/ws-star1.par.dwebops.pub.com/tcp/443/wss/p2p-websocket-star' + '/ip4/0.0.0.0/tcp/0', + // optional ws-star signaling provides a backup non-LAN peer discovery + '/dns4/ws-star1.par.dwebops.pub.com/tcp/443/wss/p2p-websocket-star' ], // Delegated Content and Peer Routing: https://github.com/ipfs/js-ipfs/pull/2195 Delegates: // [] // TODO: enable delegates diff --git a/add-on/src/lib/ipfs-client/embedded-chromesockets/libp2p.js b/add-on/src/lib/ipfs-client/embedded-chromesockets/libp2p.js index 58c3b8572..88a6abb2b 100644 --- a/add-on/src/lib/ipfs-client/embedded-chromesockets/libp2p.js +++ b/add-on/src/lib/ipfs-client/embedded-chromesockets/libp2p.js @@ -18,10 +18,14 @@ const multiaddr = require('multiaddr') class Libp2pChromeSockets extends libp2p { constructor (_options) { // this can be replaced once optional listening is supported with the below code. ref: https://github.com/libp2p/interface-transport/issues/41 - // const wsstar = new WebSocketStar({ id: _options.peerInfo.id }) + // const wsstar = new WebSocketStar({ id: _options.peerInfo.id, ignore_no_online: true }) const wsstarServers = _options.peerInfo.multiaddrs.toArray().map(String).filter(addr => addr.includes('p2p-websocket-star')) _options.peerInfo.multiaddrs.replace(wsstarServers.map(multiaddr), '/p2p-websocket-star') // the ws-star-multi module will replace this with the chosen ws-star servers - const wsstar = new WebSocketStarMulti({ servers: wsstarServers, id: _options.peerInfo.id, ignore_no_online: !wsstarServers.length || _options.wsStarIgnoreErrors }) + const wsstar = new WebSocketStarMulti({ + servers: wsstarServers, + id: _options.peerInfo.id, + ignore_no_online: true // allow scenario when all ws-stars are offline + }) const defaults = { switch: {