aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/mod
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/commands/mod')
-rw-r--r--server/src/commands/mod/ban.js19
-rw-r--r--server/src/commands/mod/dumb.js11
-rw-r--r--server/src/commands/mod/kick.js14
-rw-r--r--server/src/commands/mod/speak.js9
-rw-r--r--server/src/commands/mod/unban.js15
5 files changed, 50 insertions, 18 deletions
diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js
index e19efc2..721ad27 100644
--- a/server/src/commands/mod/ban.js
+++ b/server/src/commands/mod/ban.js
@@ -3,15 +3,19 @@
*/
exports.run = async (core, server, socket, data) => {
+ // increase rate limit chance and ignore if not admin or mod
if (socket.uType == 'user') {
- // ignore if not mod or admin
+ server._police.frisk(socket.remoteAddress, 10);
+
return;
}
+ // check user input
if (typeof data.nick !== 'string') {
return;
}
+ // find target user
let targetNick = data.nick;
let badClient = server.findSockets({ channel: socket.channel, nick: targetNick });
@@ -26,6 +30,7 @@ exports.run = async (core, server, socket, data) => {
badClient = badClient[0];
+ // i guess banning mods or admins isn't the best idea?
if (badClient.uType !== 'user') {
server.reply({
cmd: 'warn',
@@ -35,23 +40,27 @@ exports.run = async (core, server, socket, data) => {
return;
}
- let clientHash = server.getSocketHash(badClient);
- server._police.arrest(badClient.remoteAddress, clientHash);
+ // commit arrest record
+ server._police.arrest(badClient.remoteAddress, badClient.hash);
console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`);
+ // notify normal users
server.broadcast({
cmd: 'info',
text: `Banned ${targetNick}`
}, { channel: socket.channel, uType: 'user' });
+ // notify mods
server.broadcast({
cmd: 'info',
- text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${clientHash}`
+ text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}`
}, { uType: 'mod' });
- badClient.close();
+ // force connection closed
+ badClient.terminate();
+ // stats are fun
core.managers.stats.increment('users-banned');
};
diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js
index 0708fb8..675ecd6 100644
--- a/server/src/commands/mod/dumb.js
+++ b/server/src/commands/mod/dumb.js
@@ -8,15 +8,19 @@ exports.init = (core) => {
}
exports.run = async (core, server, socket, data) => {
+ // increase rate limit chance and ignore if not admin or mod
if (socket.uType == 'user') {
- // ignore if not mod or admin
+ server._police.frisk(socket.remoteAddress, 10);
+
return;
}
+ // check user input
if (typeof data.nick !== 'string') {
return;
}
+ // find target user
let badClient = server.findSockets({ channel: socket.channel, nick: data.nick });
if (badClient.length === 0) {
@@ -30,6 +34,7 @@ exports.run = async (core, server, socket, data) => {
badClient = badClient[0];
+ // likely dont need this, muting mods and admins is fine
if (badClient.uType !== 'user') {
server.reply({
cmd: 'warn',
@@ -39,19 +44,21 @@ exports.run = async (core, server, socket, data) => {
return;
}
+ // store hash in mute list
let record = core.muzzledHashes[badClient.hash] = {
dumb:true
}
+ // store allies if needed
if(data.allies && Array.isArray(data.allies)){
record.allies = data.allies;
}
+ // notify mods
server.broadcast({
cmd: 'info',
text: `${socket.nick} muzzled ${data.nick} in ${socket.channel}, userhash: ${badClient.hash}`
}, { uType: 'mod' });
-
}
exports.requiredData = ['nick'];
diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js
index 157592d..75c0d40 100644
--- a/server/src/commands/mod/kick.js
+++ b/server/src/commands/mod/kick.js
@@ -1,19 +1,23 @@
/*
- Description: Forces a change on the target socket's channel, then broadcasts event
+ Description: Forces a change on the target(s) socket's channel, then broadcasts event
*/
exports.run = async (core, server, socket, data) => {
- if (socket.uType === 'user') {
- // ignore if not mod or admin
+ // increase rate limit chance and ignore if not admin or mod
+ if (socket.uType == 'user') {
+ server._police.frisk(socket.remoteAddress, 10);
+
return;
}
+ // check user input
if (typeof data.nick !== 'string') {
if (typeof data.nick !== 'object' && !Array.isArray(data.nick)) {
return;
}
}
+ // find target user(s)
let badClients = server.findSockets({ channel: socket.channel, nick: data.nick });
if (badClients.length === 0) {
@@ -25,6 +29,7 @@ exports.run = async (core, server, socket, data) => {
return;
}
+ // check if found targets are kickable, commit kick
let newChannel = '';
let kicked = [];
for (let i = 0, j = badClients.length; i < j; i++) {
@@ -66,6 +71,7 @@ exports.run = async (core, server, socket, data) => {
text: `Kicked ${kicked.join(', ')}`
}, { channel: socket.channel, uType: 'user' });
+ // stats are fun
core.managers.stats.increment('users-kicked', kicked.length);
};
@@ -75,4 +81,4 @@ exports.info = {
name: 'kick',
usage: 'kick {nick}',
description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings'
-}; \ No newline at end of file
+};
diff --git a/server/src/commands/mod/speak.js b/server/src/commands/mod/speak.js
index 643280b..454ca94 100644
--- a/server/src/commands/mod/speak.js
+++ b/server/src/commands/mod/speak.js
@@ -4,11 +4,14 @@
*/
exports.run = async (core, server, socket, data) => {
+ // increase rate limit chance and ignore if not admin or mod
if (socket.uType == 'user') {
- // ignore if not mod or admin
+ server._police.frisk(socket.remoteAddress, 10);
+
return;
}
+ // check user input
if (typeof data.ip !== 'string' && typeof data.hash !== 'string') {
server.reply({
cmd: 'warn',
@@ -18,8 +21,8 @@ exports.run = async (core, server, socket, data) => {
return;
}
+ // find target & remove mute status
let target;
-
if (typeof data.ip === 'string') {
target = getSocketHash(data.ip);
} else {
@@ -28,11 +31,11 @@ exports.run = async (core, server, socket, data) => {
delete core.muzzledHashes[target];
+ // notify mods
server.broadcast({
cmd: 'info',
text: `${socket.nick} unmuzzled : ${target}`
}, { uType: 'mod' });
-
}
exports.info = {
diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js
index e82f0b9..9115dbd 100644
--- a/server/src/commands/mod/unban.js
+++ b/server/src/commands/mod/unban.js
@@ -3,11 +3,14 @@
*/
exports.run = async (core, server, socket, data) => {
+ // increase rate limit chance and ignore if not admin or mod
if (socket.uType == 'user') {
- // ignore if not mod or admin
+ server._police.frisk(socket.remoteAddress, 10);
+
return;
}
+ // check user input
if (typeof data.ip !== 'string' && typeof data.hash !== 'string') {
server.reply({
cmd: 'warn',
@@ -17,8 +20,8 @@ exports.run = async (core, server, socket, data) => {
return;
}
+ // find target
let mode, target;
-
if (typeof data.ip === 'string') {
mode = 'ip';
target = data.ip;
@@ -27,24 +30,28 @@ exports.run = async (core, server, socket, data) => {
target = data.hash;
}
+ // remove arrest record
server._police.pardon(target);
+ // mask ip if used
if (mode === 'ip') {
target = server.getSocketHash(target);
}
-
console.log(`${socket.nick} [${socket.trip}] unbanned ${target} in ${socket.channel}`);
+ // reply with success
server.reply({
cmd: 'info',
text: `Unbanned ${target}`
}, socket);
+ // notify mods
server.broadcast({
cmd: 'info',
text: `${socket.nick} unbanned: ${target}`
}, { uType: 'mod' });
+ // stats are fun
core.managers.stats.decrement('users-banned');
};
@@ -52,4 +59,4 @@ exports.info = {
name: 'unban',
usage: 'unban {[ip || hash]}',
description: 'Removes target ip from the ratelimiter'
-}; \ No newline at end of file
+};