Skip to content

Commit

Permalink
fix: allow scenario when all ws-stars are offline
Browse files Browse the repository at this point in the history
ws-star is optional, should not break boot process
  • Loading branch information
lidel committed Sep 11, 2019
1 parent 38a55a3 commit 8ed1a6d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions add-on/src/lib/ipfs-client/embedded-chromesockets/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions add-on/src/lib/ipfs-client/embedded-chromesockets/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 8ed1a6d

Please sign in to comment.