Skip to content

Commit

Permalink
feat: enable local discovery via libp2p-mdns
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Sep 11, 2019
1 parent 3c04858 commit 0802321
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion add-on/src/lib/ipfs-client/embedded-chromesockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const getPort = require('get-port')
// const WS = require('libp2p-websockets')
// const WSM = require('libp2p-websocket-star-multi')
const TCP = require('libp2p-tcp')
const MulticastDNS = require('libp2p-mdns')
const Bootstrap = require('libp2p-bootstrap')

const { optionDefaults } = require('../options')
Expand All @@ -44,9 +45,24 @@ async function buildConfig (opts) {
ipfsNodeConfig.libp2p = {
modules: {
transport: [new TCP()],
peerDiscovery: [new Bootstrap({ list: ipfsNodeConfig.config.Bootstrap })]
peerDiscovery: [
MulticastDNS,
new Bootstrap({ list: ipfsNodeConfig.config.Bootstrap })
]
},
config: {
peerDiscovery: {
autoDial: true,
mdns: {
enabled: true
},
bootstrap: {
enabled: true
},
websocketStar: {
enabled: true
}
},
dht: {
// TODO: check if below is needed after js-ipfs is released with DHT disabled
enabled: false
Expand Down
2 changes: 1 addition & 1 deletion add-on/src/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.optionDefaults = Object.freeze({
ipfsApiUrl: buildIpfsApiUrl(),
ipfsApiPollMs: 3000,
ipfsProxy: true, // window.ipfs
logNamespaces: 'jsipfs*,ipfs*,libp2p-delegated*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*'
logNamespaces: 'jsipfs*,ipfs*,libp2p:mdns*,libp2p-delegated*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*'
})

function buildCustomGatewayUrl () {
Expand Down

0 comments on commit 0802321

Please sign in to comment.