chore: release GreenRhombus 1.1.0
This commit is contained in:
parent
4bbcee9df2
commit
a1b58be89e
2 changed files with 49 additions and 15 deletions
62
index.js
62
index.js
|
@ -21,9 +21,9 @@ try {
|
|||
//GreenRhombus will not care about configJSONS in SVR.JS 3.x and newer
|
||||
//SVR.JS 2.x and older will fail to start with broken configuration file anyway...
|
||||
}
|
||||
var fastcgiConf = {};
|
||||
var fastcgiConfO = {};
|
||||
try {
|
||||
fastcgiConf = JSON.parse(fs.readFileSync(__dirname + "/../../../greenrhombus-config.json"));
|
||||
fastcgiConfO = JSON.parse(fs.readFileSync(__dirname + "/../../../greenrhombus-config.json"));
|
||||
} catch (ex) {
|
||||
// Use defaults
|
||||
}
|
||||
|
@ -338,10 +338,20 @@ function createFastCGIHandler(options) {
|
|||
}
|
||||
|
||||
// Load default configuration
|
||||
if (fastcgiConf.path !== undefined) fastcgiConf.path = fastcgiConf.path.replace(/([^\/])\/+$/, "$1");
|
||||
if (fastcgiConf.socketPath === undefined) {
|
||||
if (fastcgiConf.host === undefined) fastcgiConf.host = "localhost";
|
||||
if (fastcgiConf.port === undefined) fastcgiConf.port = 4000;
|
||||
if (fastcgiConfO.path !== undefined) fastcgiConfO.path = fastcgiConfO.path.replace(/([^\/])\/+$/, "$1");
|
||||
if (fastcgiConfO.socketPath === undefined) {
|
||||
if (fastcgiConfO.host === undefined) fastcgiConfO.host = "localhost";
|
||||
if (fastcgiConfO.port === undefined) fastcgiConfO.port = 4000;
|
||||
}
|
||||
if (typeof fastcgiConfO.multiConfig == "object" && fastcgiConfO.multiConfig !== null) {
|
||||
var fastcgiConfOMCK = Object.keys(fastcgiConfO.multiConfig);
|
||||
for (var i = 0; i < fastcgiConfOMCK.length; i++) {
|
||||
if (fastcgiConfO.multiConfig[fastcgiConfOMCK[i]].path !== undefined) fastcgiConfO.multiConfig[fastcgiConfOMCK[i]].path = fastcgiConfO.multiConfig[fastcgiConfOMCK[i]].path.replace(/([^\/])\/+$/, "$1");
|
||||
if (fastcgiConfO.multiConfig[fastcgiConfOMCK[i]].socketPath === undefined) {
|
||||
if (fastcgiConfO.multiConfig[fastcgiConfOMCK[i]].host === undefined) fastcgiConfO.multiConfig[fastcgiConfOMCK[i]].host = "localhost";
|
||||
if (fastcgiConfO.multiConfig[fastcgiConfOMCK[i]].port === undefined) fastcgiConfO.multiConfig[fastcgiConfOMCK[i]].port = 4000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var disableModExposeSupported = process.versions.svrjs && process.versions.svrjs.match(/^(?:Nightly-|(?:[4-9]|[123][0-9])[0-9]*\.|3\.(?:[1-9][0-9]+\.|9\.(?:[1-9])|4\.(?:(?:[3-9]|[12][0-9])[0-9]+|29)))/i);
|
||||
|
@ -404,7 +414,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
var abheaders = JSON.parse(JSON.stringify(bheaders));
|
||||
var socket = {};
|
||||
|
||||
function executeFastCGI(req, res, dh, nEnv) {
|
||||
function executeFastCGI(req, res, dh, nEnv, fastcgiConf) {
|
||||
// Function to execute FastCGI scripts
|
||||
var env = JSON.parse(JSON.stringify(process.env));
|
||||
var nEnvKeys = Object.keys(nEnv);
|
||||
|
@ -555,7 +565,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
else if(!handler.socket.destroyed) handlerConnection();
|
||||
}
|
||||
|
||||
function executeFastCGIWithEnv(a, b, req, res, pubip, port, software, dh, user, cPath) {
|
||||
function executeFastCGIWithEnv(a, b, req, res, pubip, port, software, dh, user, cPath, fastcgiConf) {
|
||||
// Function to set up environment variables and execute sCGI scripts
|
||||
var nEnv = {};
|
||||
if (typeof user != "undefined") {
|
||||
|
@ -614,11 +624,30 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
for (var i = 0; i < nhKeys.length; i++) {
|
||||
nEnv["HTTP_" + nhKeys[i].replace(/[^0-9A-Za-z]+/g, "_").toUpperCase()] = req.headers[nhKeys[i]];
|
||||
}
|
||||
executeFastCGI(req, res, dh, nEnv);
|
||||
executeFastCGI(req, res, dh, nEnv, fastcgiConf);
|
||||
}
|
||||
|
||||
var isScriptExt = scriptExts.indexOf("." + ext) != -1;
|
||||
|
||||
var fastcgiConf = fastcgiConfO;
|
||||
if (fastcgiConfO.multiConfig) {
|
||||
var hostnames = Object.keys(fastcgiConfO.multiConfig);
|
||||
for (var i = 0; i < hostnames.length; i++) {
|
||||
if (hostnames[i] == "*") {
|
||||
fastcgiConf = fastcgiConfO.multiConfig["*"];
|
||||
break;
|
||||
} else if (req.headers.host && hostnames[i].indexOf("*.") == 0 && hostnames[i] != "*.") {
|
||||
var hostnamesRoot = hostnames[i].substr(2);
|
||||
if (req.headers.host == hostnamesRoot || (req.headers.host.length > hostnamesRoot.length && req.headers.host.indexOf("." + hostnamesRoot) == req.headers.host.length - hostnamesRoot.length - 1 )) {
|
||||
fastcgiConf = fastcgiConfO.multiConfig[hostnames[i]];
|
||||
break;
|
||||
}
|
||||
} else if (req.headers.host && req.headers.host == hostnames[i]) {
|
||||
fastcgiConf = fastcgiConfO.multiConfig[hostnames[i]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fastcgiConf.path !== undefined && (href == fastcgiConf.path || href.indexOf(fastcgiConf.path + "/") == 0)) {
|
||||
try {
|
||||
|
@ -645,7 +674,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
version,
|
||||
bheaders,
|
||||
authUser,
|
||||
fastcgiConf.path
|
||||
fastcgiConf.path,
|
||||
fastcgiConf
|
||||
);
|
||||
} catch (ex) {
|
||||
if (!callServerError) {
|
||||
|
@ -712,7 +742,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
version,
|
||||
bheaders,
|
||||
authUser,
|
||||
(decodeURIComponent(href) + "/index.php").replace(/\/+/g, "/")
|
||||
(decodeURIComponent(href) + "/index.php").replace(/\/+/g, "/"),
|
||||
fastcgiConf
|
||||
);
|
||||
} catch (ex) {
|
||||
if (!callServerError) {
|
||||
|
@ -769,7 +800,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
version,
|
||||
bheaders,
|
||||
authUser,
|
||||
(decodeURIComponent(href) + "/index.cgi").replace(/\/+/g, "/")
|
||||
(decodeURIComponent(href) + "/index.cgi").replace(/\/+/g, "/"),
|
||||
fastcgiConf
|
||||
);
|
||||
} catch (ex) {
|
||||
if (!callServerError) {
|
||||
|
@ -828,7 +860,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
version,
|
||||
bheaders,
|
||||
authUser,
|
||||
decodeURIComponent(href)
|
||||
decodeURIComponent(href),
|
||||
fastcgiConf
|
||||
);
|
||||
} catch (ex) {
|
||||
if (!callServerError) {
|
||||
|
@ -911,7 +944,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
version,
|
||||
bheaders,
|
||||
authUser,
|
||||
pathp.fpth.substr(1)
|
||||
pathp.fpth.substr(1),
|
||||
fastcgiConf
|
||||
);
|
||||
} catch (ex) {
|
||||
if (!callServerError) {
|
||||
|
|
2
mod.info
2
mod.info
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"name": "GreenRhombus FastCGI client for SVR.JS",
|
||||
"version": "1.0.8"
|
||||
"version": "1.1.0"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue