This commit is contained in:
Hri7566 2022-05-24 20:22:19 +02:00
parent 442e34cbe3
commit fe3f5771c9
6 changed files with 81 additions and 8 deletions

2
.env
View File

@ -1,4 +1,4 @@
ADMINPASS=burgerass
SALT=๖ۣۜH͜r̬i͡7566
MONGO_URL=mongodb://127.0.0.1/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false
MONGO_URL=mongodb://7566:Phillies11@127.0.0.1/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false
SSL=true

View File

@ -4,10 +4,13 @@ module.exports = Object.seal({
_id_PrivateKey: process.env.SALT,
defaultUsername: "Anonymous",
// defaultRoomColor: "#3b5054",
defaultRoomColor: "#480505",
// defaultLobbyColor: "#19b4b9",
defaultLobbyColor: "#76b0db",
// defaultLobbyColor: "#76b0db",
// defaultLobbyColor2: "#801014",
defaultLobbyColor2: "#276491",
// defaultLobbyColor2: "#276491",
defaultLobbyColor: "#9900ff",
defaultLobbyColor2: "#5900af",
adminpass: process.env.ADMINPASS,
ssl: process.env.SSL,
defaultRoomSettings: {

View File

@ -10,7 +10,7 @@ const Notification = require('./Notification');
class Channel extends EventEmitter {
constructor(server, _id, settings) {
super();
this.logger = new Logger(`Room - ${ftc.normalise(_id)}`);
this.logger = new Logger(`Room - ${_id}`);
this._id = _id;
this.server = server;
this.crown;
@ -23,6 +23,7 @@ class Channel extends EventEmitter {
this.server.rooms.set(_id, this);
this.bans = new Map();
this.flags = {}
this.destroyed = false;
this.logger.log('Created');
@ -191,7 +192,9 @@ class Channel extends EventEmitter {
}
destroy() { //destroy room
if (this.destroyed) return;
if (this.ppl.size > 0) return;
this.destroyed = true;
this._id;
console.log(`Deleted room ${this._id}`);
this.settings = undefined;

View File

@ -15,6 +15,8 @@ class Client extends EventEmitter {
this.server = server;
this.participantId;
this.channel;
this.isSubscribedToAdminStream = false;
this.adminStreamInterval;
this.staticQuotas = {
room: new RateLimit(quotas.room.time)
@ -152,6 +154,22 @@ class Client extends EventEmitter {
}
});
}
sendAdminData() {
let data = {};
data.m = "data";
let channels = [];
this.server.rooms.forEach(ch => {
channels.push(ch.fetchChannelData());
});
data.channelManager = {
channels
};
this.sendArray([data]);
}
}
module.exports = Client;

View File

@ -334,6 +334,28 @@ module.exports = (cl) => {
});
cl.on('subscribe to admin stream', (msg, admin) => {
if (!admin) return;
// if (!admin) return;
if (!('password' in msg)) return;
if (msg.password !== cl.server.adminpass) return;
cl.isSubscribedToAdminStream = true;
let interval = 8000;
if ('interval_ms' in msg) interval = msg['interval_ms'];
cl.adminStreamInterval = setInterval(() => {
if (cl.isSubscribedToAdminStream == true) cl.sendAdminData();
}, interval);
});
cl.on('unsubscribe from admin stream', (msg, admin) => {
// if (!admin) return;
if (!('password' in msg)) return;
if (msg.password !== cl.server.adminpass) return;
cl.isSubscribedToAdminStream = false;
if (cl.adminStreamInterval) {
clearInterval(cl.adminStreamInterval);
cl.adminStreamInterval = undefined;
while (cl.adminStreamInterval !== undefined) {
cl.adminStreamInterval = undefined;
}
}
});
}

View File

@ -61,12 +61,39 @@ class Server extends EventEmitter {
this.connections.set(++this.connectionid, new Client(ws, req, this));
});
this.legit_m = ["a", "bye", "hi", "ch", "+ls", "-ls", "m", "n", "devices", "t", "chset", "userset", "chown", "kickban", "admin message", "color", "eval", "notification", "user_flag", "room_flag", "clear_chat", "sudo"];
this.legit_m = [
"a",
"bye",
"hi",
"ch",
"+ls",
"-ls",
"m",
"n",
"devices",
"t",
"chset",
"userset",
"chown",
"kickban",
"admin message",
"color",
"eval",
"notification",
"user_flag",
"room_flag",
"clear_chat",
"sudo",
"subscribe to admin stream",
"unsubscribe from admin stream",
"data"
];
this.welcome_motd = config.motd || "You agree to read this message.";
this._id_Private_Key = config._id_PrivateKey || "boppity";
this._id_Private_Key = config._id_PrivateKey || "amogus";
this.adminpass = config.adminpass || "Bop It";
this.adminpass = config.adminpass || "123123sucks";
}
updateRoom(data) {