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

nat-upnp

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nat-upnp - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

42

lib/nat-upnp/ssdp.js
var dgram = require('dgram'),
util = require('util'),
os = require('os'),
net = require('net'),
netroute = require('netroute'),
ip = require('ip'),
EventEmitter = require('events').EventEmitter;

@@ -131,3 +134,3 @@

Ssdp.prototype.parseResponse = function parseResponse(response, address) {
Ssdp.prototype.parseResponse = function parseResponse(response, addr, remote) {
response = response.split(/\r\n/g);

@@ -152,3 +155,38 @@

this.emit('_device', headers, address);
var interfaces = os.networkInterfaces(),
routes = netroute.getInfo(),
local;
local = routes.IPv4.concat(routes.IPv6).filter(function(route) {
if (route.gateway) {
if (ip.isEqual(remote.address, route.gateway)) return true;
}
if (route.destination && route.netmask) {
return ip.isEqual(ip.mask(remote.address, route.netmask),
ip.mask(route.destination, route.netmask));
}
if (route.destination) {
return ip.isEqual(remote.address, route.destination) ||
ip.isEqual(route.destination, '::');
}
}).map(function(route) {
return interfaces[route.interface].filter(function(addr) {
return net.isIP(addr.address) === net.isIP(route.gateway) ||
net.isIP(addr.address) === net.isIP(route.destination) ||
ip.isEqual(ip.mask(addr.address, route.netmask),
ip.mask(route.gateway, route.netmask));
}).map(function(addr) {
return addr.address;
});
}).reduce(function(prev, next) {
return prev.concat(next);
});
if (local.length === 0) {
local = addr;
} else {
local = local[0];
}
this.emit('_device', headers, local);
};

@@ -155,0 +193,0 @@

6

package.json
{
"name": "nat-upnp",
"version": "0.2.1",
"version": "0.2.2",
"main": "lib/nat-upnp",

@@ -20,4 +20,6 @@ "author": "Fedor Indutny <fedor@indutny.com>",

"request": "~2.10.0",
"async": "~0.1.22"
"async": "~0.1.22",
"netroute": "~0.2.2",
"ip": "~0.0.1"
}
}

@@ -17,3 +17,3 @@ # NAT UPnP

}, function(err) {
// Will be called on success
// Will be called once finished
});

@@ -20,0 +20,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