Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdns-js

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdns-js - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

88

lib/browser.js

@@ -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 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc