Comparing version 0.2.6 to 0.2.7
@@ -18,3 +18,5 @@ | ||
var MDNS_MULTICAST = '224.0.0.251'; | ||
internal.broadcast = function (sock, serviceType) { | ||
@@ -78,34 +80,37 @@ debug('broadcasting to', sock.address()); | ||
data.type.forEach(function (type) { | ||
var service; | ||
var serviceKey = type.toString(); | ||
if (!connection.services.hasOwnProperty(serviceKey)) { | ||
setNew('new service - %s', serviceKey); | ||
service = connection.services[serviceKey] = {type: type, addresses: []}; | ||
} | ||
else { | ||
service = connection.services[serviceKey]; | ||
} | ||
data.addresses.forEach(function (adr) { | ||
if (service.addresses.indexOf(adr) === -1) { | ||
service.addresses.push(adr); | ||
setNew('new address'); | ||
if (typeof data.type !== 'undefined') { | ||
data.type.forEach(function (type) { | ||
var service; | ||
var serviceKey = type.toString(); | ||
if (!connection.services.hasOwnProperty(serviceKey)) { | ||
setNew('new service - %s', serviceKey); | ||
service = connection.services[serviceKey] = { | ||
type: type, addresses: [] | ||
}; | ||
} | ||
var host; | ||
if (connection.addresses.hasOwnProperty(adr)) { | ||
host = connection.addresses[adr]; | ||
} | ||
else { | ||
host = connection.addresses[adr] = {address: adr}; | ||
setNew('new host'); | ||
service = connection.services[serviceKey]; | ||
} | ||
addValue({}, host, serviceKey); | ||
updateValue(data.port, host[serviceKey], 'port'); | ||
updateValue(data.host, host[serviceKey], 'host'); | ||
updateValue(data.txt, host[serviceKey], 'txt'); | ||
data.addresses.forEach(function (adr) { | ||
if (service.addresses.indexOf(adr) === -1) { | ||
service.addresses.push(adr); | ||
setNew('new address'); | ||
} | ||
var host; | ||
if (connection.addresses.hasOwnProperty(adr)) { | ||
host = connection.addresses[adr]; | ||
} | ||
else { | ||
host = connection.addresses[adr] = {address: adr}; | ||
setNew('new host'); | ||
} | ||
addValue({}, host, serviceKey); | ||
updateValue(data.port, host[serviceKey], 'port'); | ||
updateValue(data.host, host[serviceKey], 'host'); | ||
updateValue(data.txt, host[serviceKey], 'txt'); | ||
}); | ||
}); | ||
}); | ||
} | ||
@@ -121,3 +126,3 @@ | ||
debug('isNew', isNew); | ||
if (isNew) { | ||
if (isNew && data) { | ||
this.emit('update', data); | ||
@@ -158,9 +163,14 @@ } | ||
for (var i = 0; i < interfaces[key].length; i++) { | ||
var address = interfaces[key][i].address; | ||
debug('interface', key, interfaces[key]); | ||
var iface = interfaces[key][i]; | ||
//no localhost | ||
if (iface.internal) { | ||
continue; | ||
} | ||
//no IPv6 addresses | ||
if (address.indexOf(':') !== -1) { | ||
if (iface.address.indexOf(':') !== -1) { | ||
continue; | ||
} | ||
createSocket(index++, key, address, 0, bindToAddress.bind(self)); | ||
debug('interface', key, iface.address); | ||
createSocket(index++, key, | ||
iface.address, 0, bindToAddress.bind(self)); | ||
} | ||
@@ -170,3 +180,4 @@ } | ||
createSocket(index++, key, '224.0.0.251', 5353, bindToAddress.bind(self)); | ||
createSocket(index++, 'pseudo multicast', | ||
'0.0.0.0', 5353, bindToAddress.bind(self)); | ||
}.bind(this)); | ||
@@ -179,5 +190,5 @@ | ||
created++; | ||
sock.bind(port, function (err) { | ||
if (port === 5353) { | ||
sock.addMembership(address); | ||
sock.bind(port, address, function (err) { | ||
if (port === 5353 && address === '0.0.0.0') { | ||
sock.addMembership(MDNS_MULTICAST); | ||
} | ||
@@ -197,5 +208,2 @@ cb(err, interfaceIndex, networkInterface, sock); | ||
var info = sock.address(); | ||
if (info.address === '224.0.0.251') { | ||
sock.addMembership('224.0.0.251'); | ||
} | ||
@@ -202,0 +210,0 @@ var connection = { |
{ | ||
"name": "mdns-js", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -32,14 +32,9 @@ var Lab = require('lab'); | ||
it('should .discover()', function (done) { | ||
it('should .discover()', {skip: process.env.MDNS_NO_RESPONSE}, function (done) { | ||
browser.once('update', function onUpdate(data) { | ||
//mdns._byService.should.have.property('_workstation._tcp'); | ||
expect(data).to.include(['interfaceIndex', 'networkInterface', | ||
'addresses', 'query']); | ||
// if (data.query !== '_services._dns-sd._udp.local') { | ||
// console.log(data); | ||
// data.should.have.property('type'); | ||
// } | ||
done(); | ||
}); | ||
setTimeout(browser.discover.bind(browser), 500); | ||
@@ -46,0 +41,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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
79814
1814
4