aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/mod
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2020-03-06 16:39:22 +0100
committerGitHub <noreply@github.com>2020-03-06 16:39:22 +0100
commit4e0e269007af349dee969724a8a0128c0ef22dae (patch)
treedaf36b87a9863a798d201242d0bbc68d39cda56d /server/src/commands/mod
parentMerge pull request #85 from MinusGix/add_channel_invite (diff)
parentMove most uses of uType filtering to use UAC levels (diff)
downloadhackchat-4e0e269007af349dee969724a8a0128c0ef22dae.tar.gz
hackchat-4e0e269007af349dee969724a8a0128c0ef22dae.zip
Merge pull request #89 from MinusGix/nul_initial2
Added UAC and numeric user levels
Diffstat (limited to 'server/src/commands/mod')
-rw-r--r--server/src/commands/mod/ban.js10
-rw-r--r--server/src/commands/mod/dumb.js8
-rw-r--r--server/src/commands/mod/kick.js10
-rw-r--r--server/src/commands/mod/moveuser.js6
-rw-r--r--server/src/commands/mod/speak.js6
-rw-r--r--server/src/commands/mod/unban.js6
-rw-r--r--server/src/commands/mod/unbanall.js6
7 files changed, 33 insertions, 19 deletions
diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js
index dd5f01e..982c380 100644
--- a/server/src/commands/mod/ban.js
+++ b/server/src/commands/mod/ban.js
@@ -2,10 +2,12 @@
Description: Adds the target socket's ip to the ratelimiter
*/
+import * as UAC from "../utility/UAC/info";
+
// module main
export async function run(core, server, socket, data) {
// increase rate limit chance and ignore if not admin or mod
- if (socket.uType === 'user') {
+ if (!UAC.isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
}
@@ -28,7 +30,7 @@ export async function run(core, server, socket, data) {
[badClient] = badClient;
// i guess banning mods or admins isn't the best idea?
- if (badClient.uType !== 'user') {
+ if (badClient.level >= socket.level) {
return server.reply({
cmd: 'warn',
text: 'Cannot ban other mods, how rude',
@@ -44,13 +46,13 @@ export async function run(core, server, socket, data) {
server.broadcast({
cmd: 'info',
text: `Banned ${targetNick}`,
- }, { channel: socket.channel, uType: 'user' });
+ }, { channel: socket.channel, level: (level) => level < UAC.levels.moderator });
// notify mods
server.broadcast({
cmd: 'info',
text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}`,
- }, { uType: 'mod' });
+ }, { level: UAC.isModerator });
// force connection closed
badClient.terminate();
diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js
index 89aad4b..5693df2 100644
--- a/server/src/commands/mod/dumb.js
+++ b/server/src/commands/mod/dumb.js
@@ -3,6 +3,8 @@
* Author: simple
*/
+import * as UAC from "../utility/UAC/info";
+
// module constructor
export function init(core) {
if (typeof core.muzzledHashes === 'undefined') {
@@ -13,7 +15,7 @@ export function init(core) {
// module main
export async function run(core, server, socket, data) {
// increase rate limit chance and ignore if not admin or mod
- if (socket.uType === 'user') {
+ if (!UAC.isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
}
@@ -35,7 +37,7 @@ export async function run(core, server, socket, data) {
[badClient] = badClient;
// likely dont need this, muting mods and admins is fine
- if (badClient.uType !== 'user') {
+ if (badClient.level >= socket.level) {
return server.reply({
cmd: 'warn',
text: 'This trick wont work on mods and admin',
@@ -56,7 +58,7 @@ export async function run(core, server, socket, data) {
server.broadcast({
cmd: 'info',
text: `${socket.nick} muzzled ${data.nick} in ${socket.channel}, userhash: ${badClient.hash}`,
- }, { uType: 'mod' });
+ }, { level: UAC.isModerator });
return true;
}
diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js
index 3ba2f5c..0a94c6d 100644
--- a/server/src/commands/mod/kick.js
+++ b/server/src/commands/mod/kick.js
@@ -2,10 +2,12 @@
Description: Forces a change on the target(s) socket's channel, then broadcasts event
*/
+import * as UAC from "../utility/UAC/info";
+
// module main
export async function run(core, server, socket, data) {
// increase rate limit chance and ignore if not admin or mod
- if (socket.uType === 'user') {
+ if (!UAC.isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
}
@@ -36,7 +38,7 @@ export async function run(core, server, socket, data) {
// check if found targets are kickable, add them to the list if they are
const kicked = [];
for (let i = 0, j = badClients.length; i < j; i += 1) {
- if (badClients[i].uType !== 'user') {
+ if (badClients[i].level >= socket.level) {
server.reply({
cmd: 'warn',
text: 'Cannot kick other mods, how rude',
@@ -68,7 +70,7 @@ export async function run(core, server, socket, data) {
server.broadcast({
cmd: 'info',
text: `${kicked[i].nick} was banished to ?${destChannel}`,
- }, { channel: socket.channel, uType: 'mod' });
+ }, { channel: socket.channel, level: UAC.isModerator });
console.log(`${socket.nick} [${socket.trip}] kicked ${kicked[i].nick} in ${socket.channel} to ${destChannel} `);
}
@@ -86,7 +88,7 @@ export async function run(core, server, socket, data) {
server.broadcast({
cmd: 'info',
text: `Kicked ${kicked.map(k => k.nick).join(', ')}`,
- }, { channel: socket.channel, uType: 'user' });
+ }, { channel: socket.channel, level: (level) => level < UAC.levels.moderator });
// stats are fun
core.stats.increment('users-kicked', kicked.length);
diff --git a/server/src/commands/mod/moveuser.js b/server/src/commands/mod/moveuser.js
index b55c207..7eb6d83 100644
--- a/server/src/commands/mod/moveuser.js
+++ b/server/src/commands/mod/moveuser.js
@@ -2,10 +2,12 @@
Description: Removes the target socket from the current channel and forces a join event in another
*/
+import * as UAC from "../utility/UAC/info";
+
// module main
export async function run(core, server, socket, data) {
// increase rate limit chance and ignore if not admin or mod
- if (socket.uType === 'user') {
+ if (!UAC.isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
}
@@ -30,7 +32,7 @@ export async function run(core, server, socket, data) {
const badClient = badClients[0];
- if (badClient.uType !== 'user') {
+ if (badClient.level >= socket.level) {
return server.reply({
cmd: 'warn',
text: 'Cannot move other mods, how rude',
diff --git a/server/src/commands/mod/speak.js b/server/src/commands/mod/speak.js
index 5514545..48d38c6 100644
--- a/server/src/commands/mod/speak.js
+++ b/server/src/commands/mod/speak.js
@@ -3,6 +3,8 @@
* Author: simple
*/
+import * as UAC from "../utility/UAC/info";
+
// module constructor
export function init(core) {
if (typeof core.muzzledHashes === 'undefined') {
@@ -13,7 +15,7 @@ export function init(core) {
// module main
export async function run(core, server, socket, data) {
// increase rate limit chance and ignore if not admin or mod
- if (socket.uType === 'user') {
+ if (!UAC.isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
}
@@ -39,7 +41,7 @@ export async function run(core, server, socket, data) {
server.broadcast({
cmd: 'info',
text: `${socket.nick} unmuzzled : ${target}`,
- }, { uType: 'mod' });
+ }, { level: UAC.isModerator });
return true;
}
diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js
index 0d1e469..b8506f3 100644
--- a/server/src/commands/mod/unban.js
+++ b/server/src/commands/mod/unban.js
@@ -2,10 +2,12 @@
Description: Removes a target ip from the ratelimiter
*/
+import * as UAC from "../utility/UAC/info";
+
// module main
export async function run(core, server, socket, data) {
// increase rate limit chance and ignore if not admin or mod
- if (socket.uType === 'user') {
+ if (!UAC.isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
}
@@ -47,7 +49,7 @@ export async function run(core, server, socket, data) {
server.broadcast({
cmd: 'info',
text: `${socket.nick} unbanned: ${target}`,
- }, { uType: 'mod' });
+ }, { level: UAC.isModerator });
// stats are fun
core.stats.decrement('users-banned');
diff --git a/server/src/commands/mod/unbanall.js b/server/src/commands/mod/unbanall.js
index 49eeee5..e6affc4 100644
--- a/server/src/commands/mod/unbanall.js
+++ b/server/src/commands/mod/unbanall.js
@@ -2,10 +2,12 @@
Description: Clears all bans and ratelimits
*/
+import * as UAC from "../utility/UAC/info";
+
// module main
export async function run(core, server, socket) {
// increase rate limit chance and ignore if not admin or mod
- if (socket.uType === 'user') {
+ if (!UAC.isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
}
@@ -24,7 +26,7 @@ export async function run(core, server, socket) {
server.broadcast({
cmd: 'info',
text: `${socket.nick} unbanned all ip addresses`,
- }, { uType: 'mod' });
+ }, { level: UAC.isModerator });
return true;
}