From 78d24224d6bc4a665f69b9a0befa2e4a295e4957 Mon Sep 17 00:00:00 2001 From: Wolfy Date: Tue, 7 Apr 2020 14:38:57 -0400 Subject: [PATCH] Fix things fix some forgotten thigs, like adding the correct messages (legit_m) to the server... and cleaning up Quotas.js and Config.js --- Quotas.js | 72 +++++++++++++++++++++++------------------------ banned.json | 4 +-- config.js | 16 +++++------ src/Message.js | 4 +-- src/Server.js | 26 +++++++++++++++-- src/db/users.json | 38 ++++++++++++++++++++++++- 6 files changed, 109 insertions(+), 51 deletions(-) diff --git a/Quotas.js b/Quotas.js index 8953448..f706b51 100644 --- a/Quotas.js +++ b/Quotas.js @@ -1,51 +1,51 @@ module.exports = Object.seal({ - "note": { - "lobby": { - "allowance": 200, - "max": 600, - "maxHistLen": 3 + note: { + lobby: { + allowance: 200, + max: 600, + maxHistLen: 3 }, - "normal": { - "allowance": 400, - "max": 1200, - "maxHistLen": 3 + normal: { + allowance: 400, + max: 1200, + maxHistLen: 3 }, - "insane": { - "allowance": 600, - "max": 1800, - "maxHistLen": 3 + insane: { + allowance: 600, + max: 1800, + maxHistLen: 3 } }, - "chat": { - "lobby": { - "amount": 4, - "time": 4000 + chat: { + lobby: { + amount: 4, + time: 4000 }, - "normal": { - "amount": 4, - "time": 4000 + normal: { + amount: 4, + time: 4000 }, - "insane": { - "amount": 10, - "time": 4000 + insane: { + amount: 10, + time: 4000 } }, - "chown": { - "amount": 10, - "time": 5000 + chown: { + amount: 10, + time: 5000 }, - "name": { - "amount": 30, - "time": 30 * 60000 + name: { + amount: 30, + time: 30 * 60000 }, - "room": { - "time": 500 + room: { + time: 500 }, - "cursor": { - "time": 16 + cursor: { + time: 16 }, - "kickban": { - "amount": 2, - "time": 1000 + kickban: { + amount: 2, + time: 1000 } }) \ No newline at end of file diff --git a/banned.json b/banned.json index 75d98b2..1610ea1 100644 --- a/banned.json +++ b/banned.json @@ -1,3 +1,3 @@ [ - "1.2.3.4" -] + +] \ No newline at end of file diff --git a/config.js b/config.js index 84ce5f7..0497b8a 100644 --- a/config.js +++ b/config.js @@ -1,10 +1,10 @@ module.exports = Object.seal({ - "port": "8080", - "motd": "You agree to read this message.", - "_id_PrivateKey": "boppity", - "defaultUsername": "Anonymous", - "defaultRoomColor": "#3b5054", - "defaultLobbyColor": "#19b4b9", - "defaultLobbyColor2": "#801014", - "adminpass": "adminpass" + port: "8080", + motd: "You agree to read this message.", + _id_PrivateKey: "boppity", + defaultUsername: "Anonymous", + defaultRoomColor: "#3b5054", + defaultLobbyColor: "#19b4b9", + defaultLobbyColor2: "#801014", + adminpass: "adminpass" }) diff --git a/src/Message.js b/src/Message.js index 1d8d319..5a26e5b 100644 --- a/src/Message.js +++ b/src/Message.js @@ -157,7 +157,7 @@ module.exports = (cl) => { cl.on("bye", msg => { cl.destroy(); }) - cl.on("admin message", msg => { + cl.on("admin message" || "adminmsg" || "admin msg", msg => { if (!(cl.channel && cl.participantId)) return; if (!msg.hasOwnProperty('password') || !msg.hasOwnProperty('msg')) return; if (typeof msg.msg != 'object') return; @@ -189,7 +189,7 @@ module.exports = (cl) => { if (!dbentry) return; dbentry.color = msg.color; dbentry.noteColor = msg.color; - //user.updatedb(); + user.updatedb(); cl.server.rooms.forEach((room) => { room.updateParticipant(usr.participantId, { color: msg.color, diff --git a/src/Server.js b/src/Server.js index fae58ce..362eca9 100644 --- a/src/Server.js +++ b/src/Server.js @@ -9,7 +9,6 @@ class Server extends EventEmitter { port: config.port, backlog: 100, verifyClient: (info) => { - //if (banned.includes(info.req.headers['x-forwarded-for'].split(",")[0].replace('::ffff:', ''))) return false; if (banned.includes((info.req.connection.remoteAddress).replace("::ffff:", ""))) return false; return true; } @@ -21,7 +20,30 @@ class Server extends EventEmitter { this.wss.on('connection', (ws, req) => { 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"] + this.legit_m = [ + "a", + "bye", + "hi", + "ch", + "+ls", + "-ls", + "m", + "n", + "devices", + "t", + "chset", + "userset", + "chown", + "kickban", + + "admin message", + "admin_color", + "admin_noteColor", + "admin_chset", + "admin_chown", + "admin_kickban", + "admin_notification" + ]; this.welcome_motd = config.motd || "You agree to read this message."; this._id_Private_Key = config._id_PrivateKey || "boppity"; this.defaultUsername = config.defaultUsername || "Anonymous"; diff --git a/src/db/users.json b/src/db/users.json index 0967ef4..27c5276 100644 --- a/src/db/users.json +++ b/src/db/users.json @@ -1 +1,37 @@ -{} +{ + "999d1d8bbe8cf06eb15e5d56": { + "color": "#7fd09e", + "noteColor": "#7fd09e", + "name": "Anonymous", + "_id": "999d1d8bbe8cf06eb15e5d56", + "ip": "108.169.248.183" + }, + "a6a35eb1546b541be5f11cc8": { + "color": "#d3de03", + "noteColor": "#d3de03", + "name": "Anonymous", + "_id": "a6a35eb1546b541be5f11cc8", + "ip": "177.18.157.8" + }, + "c6d435dd7fa48be7cea001ba": { + "color": "#FF00FF", + "noteColor": "#FF00FF", + "name": "Wolfy", + "_id": "c6d435dd7fa48be7cea001ba", + "ip": "75.91.45.152" + }, + "931fb786761b12807265771b": { + "color": "#612196", + "noteColor": "#612196", + "name": "Anonymous", + "_id": "931fb786761b12807265771b", + "ip": "185.180.198.66" + }, + "63c4f4f0b079c466e5dd6df6": { + "color": "#b2b055", + "noteColor": "#b2b055", + "name": "Anonymous", + "_id": "63c4f4f0b079c466e5dd6df6", + "ip": "95.110.114.123" + } +} \ No newline at end of file