mirror of https://github.com/calzoneman/sync.git
ACP event log
This commit is contained in:
parent
afa17165f7
commit
0a480515d7
23
lib/acp.js
23
lib/acp.js
|
@ -16,6 +16,10 @@ var util = require("./utilities");
|
||||||
var Config = require("./config");
|
var Config = require("./config");
|
||||||
var Server = require("./server");
|
var Server = require("./server");
|
||||||
|
|
||||||
|
function eventUsername(user) {
|
||||||
|
return user.name + "@" + user.ip;
|
||||||
|
}
|
||||||
|
|
||||||
function handleAnnounce(user, data) {
|
function handleAnnounce(user, data) {
|
||||||
var sv = Server.getServer();
|
var sv = Server.getServer();
|
||||||
|
|
||||||
|
@ -24,10 +28,14 @@ function handleAnnounce(user, data) {
|
||||||
text: data.content,
|
text: data.content,
|
||||||
from: user.name
|
from: user.name
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Logger.eventlog.log("[acp] " + eventUsername(user) + " opened announcement `" +
|
||||||
|
data.title + "`");
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAnnounceClear(user) {
|
function handleAnnounceClear(user) {
|
||||||
Server.getServer().announce(null);
|
Server.getServer().announce(null);
|
||||||
|
Logger.eventlog.log("[acp] " + eventUsername(user) + " cleared announcement");
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleGlobalBan(user, data) {
|
function handleGlobalBan(user, data) {
|
||||||
|
@ -39,6 +47,8 @@ function handleGlobalBan(user, data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.eventlog.log("[acp] " + eventUsername(user) + " global banned " + data.ip);
|
||||||
|
|
||||||
db.listGlobalBans(function (err, bans) {
|
db.listGlobalBans(function (err, bans) {
|
||||||
if (err) {
|
if (err) {
|
||||||
user.socket.emit("errMessage", {
|
user.socket.emit("errMessage", {
|
||||||
|
@ -68,6 +78,9 @@ function handleGlobalBanDelete(user, data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.eventlog.log("[acp] " + eventUsername(user) + " un-global banned " +
|
||||||
|
data.ip);
|
||||||
|
|
||||||
db.listGlobalBans(function (err, bans) {
|
db.listGlobalBans(function (err, bans) {
|
||||||
if (err) {
|
if (err) {
|
||||||
user.socket.emit("errMessage", {
|
user.socket.emit("errMessage", {
|
||||||
|
@ -144,6 +157,8 @@ function handleSetRank(user, data) {
|
||||||
msg: err
|
msg: err
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Logger.eventlog.log("[acp] " + eventUsername(user) + " set " + name +
|
||||||
|
"'s global_rank to " + rank);
|
||||||
user.socket.emit("acp-set-rank", data);
|
user.socket.emit("acp-set-rank", data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -181,6 +196,9 @@ function handleResetPassword(user, data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.eventlog.log("[acp] " + eventUsername(user) + " initialized a " +
|
||||||
|
"password recovery for " + name);
|
||||||
|
|
||||||
user.socket.emit("errMessage", {
|
user.socket.emit("errMessage", {
|
||||||
msg: "Reset link: " + Config.get("http.domain") +
|
msg: "Reset link: " + Config.get("http.domain") +
|
||||||
"/account/passwordrecover/" + hash
|
"/account/passwordrecover/" + hash
|
||||||
|
@ -229,6 +247,7 @@ function handleDeleteChannel(user, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
db.channels.drop(name, function (err) {
|
db.channels.drop(name, function (err) {
|
||||||
|
Logger.eventlog.log("[acp] " + eventUsername(user) + " deleted channel " + name);
|
||||||
if (err) {
|
if (err) {
|
||||||
user.socket.emit("errMessage", {
|
user.socket.emit("errMessage", {
|
||||||
msg: err
|
msg: err
|
||||||
|
@ -262,6 +281,8 @@ function handleForceUnload(user, data) {
|
||||||
users.forEach(function (u) {
|
users.forEach(function (u) {
|
||||||
u.kick("Channel shutting down");
|
u.kick("Channel shutting down");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Logger.eventlog.log("[acp] " + eventUsername(user) + " forced unload of " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init(user) {
|
function init(user) {
|
||||||
|
@ -295,7 +316,7 @@ function init(user) {
|
||||||
}
|
}
|
||||||
user.socket.emit("acp-gbanlist", flat);
|
user.socket.emit("acp-gbanlist", flat);
|
||||||
});
|
});
|
||||||
Logger.eventlog.log("[acp] Initialized ACP for " + user.name + "@" + user.ip);
|
Logger.eventlog.log("[acp] Initialized ACP for " + eventUsername(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.init = init;
|
module.exports.init = init;
|
||||||
|
|
|
@ -370,6 +370,7 @@ function handleDeleteChannel(req, res) {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
db.channels.drop(name, function (err) {
|
db.channels.drop(name, function (err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
Logger.eventlog.log("[channel] " + loginName + "@" +
|
Logger.eventlog.log("[channel] " + loginName + "@" +
|
||||||
|
@ -688,6 +689,7 @@ function handlePasswordRecover(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
db.deletePasswordReset(hash);
|
db.deletePasswordReset(hash);
|
||||||
|
Logger.eventlog.log("[account] " + ip + " recovered password for " + row.name);
|
||||||
|
|
||||||
sendJade(res, "account-passwordrecover", {
|
sendJade(res, "account-passwordrecover", {
|
||||||
recovered: true,
|
recovered: true,
|
||||||
|
|
|
@ -100,6 +100,13 @@ function handleReadHttplog(req, res) {
|
||||||
readLog(res, path.join(__dirname, "..", "..", "http.log"), 1048576);
|
readLog(res, path.join(__dirname, "..", "..", "http.log"), 1048576);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a request to read the event log
|
||||||
|
*/
|
||||||
|
function handleReadEventlog(req, res) {
|
||||||
|
readLog(res, path.join(__dirname, "..", "..", "events.log"), 1048576);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a request to read a channel log
|
* Handles a request to read a channel log
|
||||||
*/
|
*/
|
||||||
|
@ -117,6 +124,7 @@ module.exports = {
|
||||||
app.get("/acp/syslog", checkAdmin(handleReadSyslog));
|
app.get("/acp/syslog", checkAdmin(handleReadSyslog));
|
||||||
app.get("/acp/errlog", checkAdmin(handleReadErrlog));
|
app.get("/acp/errlog", checkAdmin(handleReadErrlog));
|
||||||
app.get("/acp/httplog", checkAdmin(handleReadHttplog));
|
app.get("/acp/httplog", checkAdmin(handleReadHttplog));
|
||||||
|
app.get("/acp/eventlog", checkAdmin(handleReadEventlog));
|
||||||
app.get("/acp/chanlog/:name", checkAdmin(handleReadChanlog));
|
app.get("/acp/chanlog/:name", checkAdmin(handleReadChanlog));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,7 +114,8 @@ html(lang="en")
|
||||||
h3 Event Log
|
h3 Event Log
|
||||||
strong Filter event types
|
strong Filter event types
|
||||||
select#acp-eventlog-filter.form-control(multiple="multiple", style="max-width: 25%")
|
select#acp-eventlog-filter.form-control(multiple="multiple", style="max-width: 25%")
|
||||||
pre#acp-eventlog-text(style="margin-top: 20px")
|
button#acp-eventlog-refresh.btn.btn-default Refresh
|
||||||
|
pre#acp-eventlog-text
|
||||||
#acp-stats.acp-panel.col-md-12(style="display: none")
|
#acp-stats.acp-panel.col-md-12(style="display: none")
|
||||||
h3 User Count
|
h3 User Count
|
||||||
canvas#stat_users(width="100%", height="400")
|
canvas#stat_users(width="100%", height="400")
|
||||||
|
|
|
@ -11,3 +11,18 @@
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#acp-eventlog-text {
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
max-height: 500px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#acp-eventlog-refresh {
|
||||||
|
margin-top: 20px;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
window.socket.on("connect", function () {
|
window.socket.on("connect", function () {
|
||||||
window.socket.emit("initACP");
|
window.socket.emit("initACP");
|
||||||
window.socket.emit("acp-list-activechannels");
|
window.socket.emit("acp-list-activechannels");
|
||||||
|
readEventlog();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.socket.on("errMessage", function (data) {
|
window.socket.on("errMessage", function (data) {
|
||||||
|
@ -57,6 +58,12 @@ function readHttplog() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readEventlog() {
|
||||||
|
$.ajax(location.protocol + "//" + location.host + "/acp/eventlog").done(function (data) {
|
||||||
|
handleEventLog(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function readChanlog(name) {
|
function readChanlog(name) {
|
||||||
$.ajax(location.protocol + "//" + location.host + "/acp/chanlog/" + name).done(function (data) {
|
$.ajax(location.protocol + "//" + location.host + "/acp/chanlog/" + name).done(function (data) {
|
||||||
$("#acp-log").text(data);
|
$("#acp-log").text(data);
|
||||||
|
@ -389,6 +396,51 @@ $("#acp-lchannels-refresh").click(function () {
|
||||||
socket.emit("acp-list-activechannels");
|
socket.emit("acp-list-activechannels");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Event log */
|
||||||
|
|
||||||
|
function getEventKey(line) {
|
||||||
|
var left = line.indexOf("[", 1);
|
||||||
|
var right = line.indexOf("]", left);
|
||||||
|
return line.substring(left+1, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEventLog(data) {
|
||||||
|
data = data.split("\n").filter(function (ln) { return ln.indexOf("[") === 0; });
|
||||||
|
var keys = {};
|
||||||
|
data.forEach(function (ln) {
|
||||||
|
keys[getEventKey(ln)] = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#acp-eventlog-text").data("lines", data);
|
||||||
|
|
||||||
|
$("#acp-eventlog-filter").html("");
|
||||||
|
for (var k in keys) {
|
||||||
|
$("<option/>").attr("value", k)
|
||||||
|
.text(k)
|
||||||
|
.appendTo($("#acp-eventlog-filter"));
|
||||||
|
}
|
||||||
|
|
||||||
|
filterEventLog();
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterEventLog() {
|
||||||
|
var selected = $("#acp-eventlog-filter").val();
|
||||||
|
var all = selected == null || selected.length === 0;
|
||||||
|
var lines = $("#acp-eventlog-text").data("lines");
|
||||||
|
var show = [];
|
||||||
|
lines.forEach(function (ln) {
|
||||||
|
if (all || selected.indexOf(getEventKey(ln)) !== -1) {
|
||||||
|
show.push(ln);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#acp-eventlog-text").text(show.join("\n"));
|
||||||
|
$("#acp-eventlog-text").scrollTop($("#acp-eventlog-text").prop("scrollHeight"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#acp-eventlog-filter").change(filterEventLog);
|
||||||
|
$("#acp-eventlog-refresh").click(readEventlog);
|
||||||
|
|
||||||
/* Initialize keyed table sorts */
|
/* Initialize keyed table sorts */
|
||||||
$("table").each(function () {
|
$("table").each(function () {
|
||||||
var table = $(this);
|
var table = $(this);
|
||||||
|
|
Loading…
Reference in New Issue