Skip to content

Commit

Permalink
Quick fix for if a service's "ControlURL" is hosted on a different po…
Browse files Browse the repository at this point in the history
…rt than the root device.
  • Loading branch information
TooTallNate committed Oct 5, 2010
1 parent e6f0901 commit cacfad5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/upnp.js
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cacfad5

Please sign in to comment.