libp2p-mdns
Advanced tools
Comparing version 0.4.0 to 0.5.0
{ | ||
"name": "libp2p-mdns", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Node.js libp2p mDNS discovery implementation for peer discovery", | ||
@@ -36,3 +36,2 @@ "main": "src/index.js", | ||
"chai": "^3.5.0", | ||
"libp2p-ipfs-nodejs": "^0.16.4", | ||
"pre-commit": "^1.2.0" | ||
@@ -39,0 +38,0 @@ }, |
@@ -15,3 +15,3 @@ 'use strict' | ||
class MulticastDNS extends EventEmitter { | ||
constructor (node, options) { | ||
constructor (peerInfo, options) { | ||
super() | ||
@@ -21,13 +21,8 @@ options = options || {} | ||
const broadcast = options.broadcast !== false | ||
const interval = options.interval || (1e3 * 5) // default: 5 seconds | ||
const interval = options.interval || (1e3 * 10) // default: 10 seconds | ||
const serviceTag = options.serviceTag || '_ipfs-discovery._udp' | ||
const verify = options.verify === true | ||
const port = options.port || 5353 | ||
const peerInfo = node.peerInfo | ||
const self = this // for event emitter | ||
const mdns = multicastDNS({ | ||
port: port, | ||
loopback: false | ||
}) | ||
const mdns = multicastDNS({ port: port }) | ||
@@ -94,3 +89,3 @@ // query the network | ||
Peer.create(peerId, function (err, peerFound) { | ||
Peer.create(peerId, (err, peerFound) => { | ||
if (err) { | ||
@@ -100,23 +95,10 @@ return log('Error creating PeerInfo from new found peer', err) | ||
multiaddrs.forEach(function (addr) { | ||
multiaddrs.forEach((addr) => { | ||
peerFound.multiaddr.add(addr) | ||
}) | ||
attemptDial(peerFound) | ||
self.emit('peer', peerFound) | ||
}) | ||
} | ||
function attemptDial (peer) { | ||
if (verify) { | ||
node.dialByPeerInfo(peer, (err) => { | ||
if (err) { | ||
return log('Was not able to connect to new found peer', err) | ||
} | ||
self.emit('peer', peer) | ||
}) | ||
} else { | ||
self.emit('peer', peer) | ||
} | ||
} | ||
// answer to queries | ||
@@ -123,0 +105,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
11913
214