mirror of https://github.com/calzoneman/sync.git
Hopefully prevent more webserver crashes
This commit is contained in:
parent
5b793710c3
commit
d75c8dd230
|
@ -138,10 +138,10 @@ function handleIndex(req, res) {
|
|||
var channels = Server.getServer().packChannelList(true);
|
||||
channels.sort(function (a, b) {
|
||||
if (a.usercount === b.usercount) {
|
||||
return a.uniqueName > b.uniqueName ? 1 : -1;
|
||||
return a.uniqueName > b.uniqueName ? -1 : 1;
|
||||
}
|
||||
|
||||
return a.usercount - b.usercount;
|
||||
return b.usercount - a.usercount;
|
||||
});
|
||||
|
||||
sendJade(res, "index", {
|
||||
|
@ -224,6 +224,7 @@ function handleContactPage(req, res) {
|
|||
function static(dir) {
|
||||
dir = path.join(__dirname, dir);
|
||||
return function (req, res) {
|
||||
try {
|
||||
if (isSuspicious(req)) {
|
||||
logRequest(req, 403);
|
||||
res.status(403);
|
||||
|
@ -247,6 +248,10 @@ function static(dir) {
|
|||
res.send(err.status);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
Logger.errlog.log(e);
|
||||
Logger.errlog.log(e.trace);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -284,6 +289,15 @@ module.exports = {
|
|||
require("./account").init(app);
|
||||
require("./acp").init(app);
|
||||
app.use(static(path.join("..", "..", "www")));
|
||||
app.use(function (err, req, res, next) {
|
||||
if (err) {
|
||||
Logger.errlog.log(err);
|
||||
Logger.errlog.log(err.stack);
|
||||
res.send(500);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
logRequest: logRequest,
|
||||
|
|
Loading…
Reference in New Issue