Permalink
Browse files

Quick fix for if a service's "ControlURL" is hosted on a different po…

…rt than the root device.
  • Loading branch information...
1 parent e6f0901 commit cacfad5e0011546f353e8e277ddd325f1f7171eb @TooTallNate committed Oct 5, 2010
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/upnp.js
View
@@ -71,7 +71,10 @@ function searchGateway(timeout, callback) {
var ipurl = resbuf.match(/<controlURL>(.+?)<\/controlURL>/i)[1].trim()
socket.close();
clearTimeout(t);
- callback(null, new Gateway(l.port, l.hostname, ipurl));
+ var controlUrl = url.parse(ipurl);
+ controlUrl.__proto__ = l;
+ console.log(controlUrl);
+ callback(null, new Gateway(controlUrl.port, controlUrl.hostname, controlUrl.pathname));
});
});
request.end();
@@ -172,7 +175,7 @@ Gateway.prototype._getSOAPResponse = function(soap, func, callback) {
var s = new Buffer(SOAP_ENV_PRE+soap+SOAP_ENV_POST, "utf8");
var client = http.createClient(this.port, this.host);
var request = client.request("POST", this.path, {
- "Host" : this.host,
+ "Host" : this.host + (this.port != 80 ? ":" + this.port : ""),
"SOAPACTION" : '"' + WANIP + '#' + func + '"',
"Content-Type" : "text/xml",
"Content-Length" : s.length

0 comments on commit cacfad5

Please sign in to comment.