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.5 to 0.2.6

79

lib/browser.js

@@ -41,7 +41,72 @@

var data = decoder.decodeMessage(message);
var isNew = false;
function setNew(/*msg*/) {
isNew = true;
debug('new on %s, because %s',
connection.networkInterface, util.format.apply(null, arguments));
}
function updateValue(src, dst, name) {
if (JSON.stringify(dst[name]) !== JSON.stringify(src)) {
setNew('updated host.%s', name);
dst[name] = src;
}
}
function addValue(src, dst, name) {
if (typeof dst[name] === 'undefined') {
setNew('added host.%s', name);
dst[name] = src;
}
}
if (data) {
data.interfaceIndex = connection.interfaceIndex;
data.networkInterface = connection.networkInterface;
data.addresses.push(remote.address);
if (!connection.services) {
connection.services = {};
}
if (!connection.addresses) {
connection.addresses = {};
}
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');
}
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');
});
});
/**

@@ -54,3 +119,6 @@ * Update event

*/
this.emit('update', data);
debug('isNew', isNew);
if (isNew) {
this.emit('update', data);
}
}

@@ -79,3 +147,4 @@ };

this._all = new EventEmitter();
var services = {};
var addresses = {};
var connections = [];

@@ -133,3 +202,5 @@ var created = 0;

interfaceIndex: interfaceIndex,
networkInterface: networkInterface
networkInterface: networkInterface,
services: services,
addresses: addresses
};

@@ -168,2 +239,4 @@

debug('stopping');
debug('connection.services', services);
debug('connection.addresses', addresses);
for (var i = 0; i < connections.length; i++) {

@@ -170,0 +243,0 @@ var socket = connections[i].socket;

2

package.json
{
"name": "mdns-js",
"version": "0.2.5",
"version": "0.2.6",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

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