Add cloudflared socket handler

pull/1427/head
Louis Lam 3 years ago
parent 7d3cbff794
commit 44fb2a88f2

@ -133,6 +133,7 @@ const { statusPageSocketHandler } = require("./socket-handlers/status-page-socke
const databaseSocketHandler = require("./socket-handlers/database-socket-handler");
const TwoFA = require("./2fa");
const StatusPage = require("./model/status_page");
const { cloudflaredSocketHandler } = require("./socket-handlers/cloudflared-socket-handler");
app.use(express.json());
@ -1319,6 +1320,7 @@ exports.entryPage = "dashboard";
// Status Page Socket Handler for admin only
statusPageSocketHandler(socket);
cloudflaredSocketHandler(socket);
databaseSocketHandler(socket);
debug("added all socket handlers");

@ -0,0 +1,19 @@
const { checkLogin } = require("../util-server");
const prefix = "cloudflared_";
module.exports.cloudflaredSocketHandler = (socket) => {
socket.on(prefix + "start", async (callback) => {
try {
checkLogin(socket);
} catch (error) {
callback({
ok: false,
msg: error.message,
});
}
});
};
Loading…
Cancel
Save