Comparing version 0.2.0 to 0.2.1
@@ -149,2 +149,3 @@ var nat = require('../nat-upnp'), | ||
this.findGateway(function(err, gateway, address) { | ||
if (err) return callback(err); | ||
gateway.run('GetExternalIPAddress', [], function(err, data) { | ||
@@ -168,8 +169,18 @@ if (err) return callback(err); | ||
Client.prototype.findGateway = function findGateway(callback) { | ||
var p = this.ssdp.search( | ||
'urn:schemas-upnp-org:device:InternetGatewayDevice:1' | ||
); | ||
var timeout, | ||
timeouted = false, | ||
p = this.ssdp.search( | ||
'urn:schemas-upnp-org:device:InternetGatewayDevice:1' | ||
); | ||
timeout = setTimeout(function() { | ||
timeouted = true; | ||
p.emit('end'); | ||
callbacK(new Error('timeout')); | ||
}, 5000); | ||
p.on('device', function(info, address) { | ||
if (timeouted) return; | ||
p.emit('end'); | ||
clearTimeout(timeout); | ||
@@ -176,0 +187,0 @@ // Create gateway |
{ | ||
"name": "nat-upnp", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "lib/nat-upnp", | ||
@@ -5,0 +5,0 @@ "author": "Fedor Indutny <fedor@indutny.com>", |
18231
509