Fixed bug with wildcard in domain name selectors
This commit is contained in:
parent
e6a016fa47
commit
ba62eca92c
2 changed files with 11 additions and 11 deletions
20
index.js
20
index.js
|
@ -25,7 +25,7 @@ Mod.prototype.callback = function callback(req, res, serverconsole, responseEnd,
|
||||||
break;
|
break;
|
||||||
} else if (req.headers.host && hostnames[i].indexOf("*.") == 0 && hostnames[i] != "*.") {
|
} else if (req.headers.host && hostnames[i].indexOf("*.") == 0 && hostnames[i] != "*.") {
|
||||||
var hostnamesRoot = hostnames[i].substr(2);
|
var hostnamesRoot = hostnames[i].substr(2);
|
||||||
if (req.headers.host == hostnamesRoot || req.headers.host.indexOf("." + hostnamesRoot) == req.headers.host.length - hostnamesRoot.length - 1) {
|
if (req.headers.host == hostnamesRoot || (req.headers.host.length > hostnamesRoot.length && req.headers.host.indexOf("." + hostnamesRoot) == req.headers.host.length - hostnamesRoot.length - 1)) {
|
||||||
matchingHostname = hostnames[i];
|
matchingHostname = hostnames[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ Mod.prototype.callback = function callback(req, res, serverconsole, responseEnd,
|
||||||
if (!port) port = 80;
|
if (!port) port = 80;
|
||||||
if (!securePort && secureHostname) securePort = 443;
|
if (!securePort && secureHostname) securePort = 443;
|
||||||
if (!hostname) {
|
if (!hostname) {
|
||||||
callServerError(500, "reverse-proxy-mod/1.1.2", new Error("Proxy server is misconfigured. Hostname property is missing."));
|
callServerError(500, "reverse-proxy-mod/1.1.3", new Error("Proxy server is misconfigured. Hostname property is missing."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -94,11 +94,11 @@ Mod.prototype.callback = function callback(req, res, serverconsole, responseEnd,
|
||||||
}).on("error", (ex) => {
|
}).on("error", (ex) => {
|
||||||
try {
|
try {
|
||||||
if (ex.code == "ENOTFOUND" || ex.code == "EHOSTUNREACH" || ex.code == "ECONNREFUSED") {
|
if (ex.code == "ENOTFOUND" || ex.code == "EHOSTUNREACH" || ex.code == "ECONNREFUSED") {
|
||||||
callServerError(503, "reverse-proxy-mod/1.1.2", ex); //Server error
|
callServerError(503, "reverse-proxy-mod/1.1.3", ex); //Server error
|
||||||
} else if (ex.code == "ETIMEDOUT") {
|
} else if (ex.code == "ETIMEDOUT") {
|
||||||
callServerError(504, "reverse-proxy-mod/1.1.2", ex); //Server error
|
callServerError(504, "reverse-proxy-mod/1.1.3", ex); //Server error
|
||||||
} else {
|
} else {
|
||||||
callServerError(502, "reverse-proxy-mod/1.1.2", ex); //Server error
|
callServerError(502, "reverse-proxy-mod/1.1.3", ex); //Server error
|
||||||
}
|
}
|
||||||
} catch (ex) {}
|
} catch (ex) {}
|
||||||
serverconsole.errmessage("Client fails to recieve content."); //Log into SVR.JS
|
serverconsole.errmessage("Client fails to recieve content."); //Log into SVR.JS
|
||||||
|
@ -133,17 +133,17 @@ Mod.prototype.callback = function callback(req, res, serverconsole, responseEnd,
|
||||||
} catch (ex) {}
|
} catch (ex) {}
|
||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
callServerError(502, "reverse-proxy-mod/1.1.2", ex); //Server error
|
callServerError(502, "reverse-proxy-mod/1.1.3", ex); //Server error
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
proxy.on("error", function (ex) {
|
proxy.on("error", function (ex) {
|
||||||
try {
|
try {
|
||||||
if (ex.code == "ENOTFOUND" || ex.code == "EHOSTUNREACH" || ex.code == "ECONNREFUSED") {
|
if (ex.code == "ENOTFOUND" || ex.code == "EHOSTUNREACH" || ex.code == "ECONNREFUSED") {
|
||||||
callServerError(503, "reverse-proxy-mod/1.1.2", ex); //Server error
|
callServerError(503, "reverse-proxy-mod/1.1.3", ex); //Server error
|
||||||
} else if (ex.code == "ETIMEDOUT") {
|
} else if (ex.code == "ETIMEDOUT") {
|
||||||
callServerError(504, "reverse-proxy-mod/1.1.2", ex); //Server error
|
callServerError(504, "reverse-proxy-mod/1.1.3", ex); //Server error
|
||||||
} else {
|
} else {
|
||||||
callServerError(502, "reverse-proxy-mod/1.1.2", ex); //Server error
|
callServerError(502, "reverse-proxy-mod/1.1.3", ex); //Server error
|
||||||
}
|
}
|
||||||
} catch (ex) {}
|
} catch (ex) {}
|
||||||
serverconsole.errmessage("Client fails to recieve content."); //Log into SVR.JS
|
serverconsole.errmessage("Client fails to recieve content."); //Log into SVR.JS
|
||||||
|
@ -156,7 +156,7 @@ Mod.prototype.callback = function callback(req, res, serverconsole, responseEnd,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if ((href == "/reverse-proxy-config.json" || (os.platform() == "win32" && href.toLowerCase() == "/reverse-proxy-config.json")) && path.normalize(__dirname + "/../../..") == process.cwd()) {
|
} else if ((href == "/reverse-proxy-config.json" || (os.platform() == "win32" && href.toLowerCase() == "/reverse-proxy-config.json")) && path.normalize(__dirname + "/../../..") == process.cwd()) {
|
||||||
callServerError(403, "reverse-proxy-mod/1.1.2");
|
callServerError(403, "reverse-proxy-mod/1.1.3");
|
||||||
} else {
|
} else {
|
||||||
elseCallback();
|
elseCallback();
|
||||||
}
|
}
|
||||||
|
|
2
mod.info
2
mod.info
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"name": "Reverse proxy mod for SVR.JS 3.x",
|
"name": "Reverse proxy mod for SVR.JS 3.x",
|
||||||
"version": "1.1.2"
|
"version": "1.1.3"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue