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.js11
-rw-r--r--server/src/commands/mod/kick.js6
-rw-r--r--server/src/commands/mod/unban.js12
3 files changed, 21 insertions, 8 deletions
diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js
index fde1ad8..1880ef3 100644
--- a/server/src/commands/mod/ban.js
+++ b/server/src/commands/mod/ban.js
@@ -10,7 +10,11 @@ exports.run = async (core, server, socket, data) => {
return;
}
- let targetNick = String(data.nick);
+ if (typeof data.nick !== 'string') {
+ return;
+ }
+
+ let targetNick = data.nick;
let badClient = null;
for (let client of server.clients) {
// Find badClient's socket
@@ -38,11 +42,12 @@ exports.run = async (core, server, socket, data) => {
return;
}
- // TODO: ratelimiting here
// TODO: add reference to banned users nick or unban by nick cmd
- //POLICE.arrest(getAddress(badClient))
+ server._police.arrest(badClient.remoteAddress);
// TODO: add event to log?
+
console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`);
+
server.broadcast({
cmd: 'info',
text: `Banned ${targetNick}`
diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js
index 5cd524d..a730caf 100644
--- a/server/src/commands/mod/kick.js
+++ b/server/src/commands/mod/kick.js
@@ -10,7 +10,11 @@ exports.run = async (core, server, socket, data) => {
return;
}
- let targetNick = String(data.nick);
+ if (typeof data.nick !== 'string') {
+ return;
+ }
+
+ let targetNick = data.nick;
let badClient = null;
for (let client of server.clients) {
// Find badClient's socket
diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js
index cc1016a..193b614 100644
--- a/server/src/commands/mod/unban.js
+++ b/server/src/commands/mod/unban.js
@@ -10,11 +10,15 @@ exports.run = async (core, server, socket, data) => {
return;
}
- let ip = String(data.ip);
- let nick = String(data.nick); // for future upgrade
+ if (typeof data.ip !== 'string') {
+ return;
+ }
+
+ let ip = data.ip;
+ let nick = data.nick; // for future upgrade
- // TODO: remove ip from ratelimiter
- // POLICE.pardon(ip)
+ // TODO: support remove by nick future upgrade
+ server._police.pardon(badClient.remoteAddress);
console.log(`${socket.nick} [${socket.trip}] unbanned ${/*nick || */ip} in ${socket.channel}`);
server.reply({