From 949404cd1aad8492ae0338130f16054adfa38ab7 Mon Sep 17 00:00:00 2001 From: Neel Kamath Date: Sun, 13 May 2018 16:37:56 +0530 Subject: Prevent fucking shit up --- server/src/commands/mod/unban.js | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 server/src/commands/mod/unban.js (limited to 'server/src/commands/mod/unban.js') diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js new file mode 100644 index 0000000..e82f0b9 --- /dev/null +++ b/server/src/commands/mod/unban.js @@ -0,0 +1,55 @@ +/* + Description: Removes a target ip from the ratelimiter +*/ + +exports.run = async (core, server, socket, data) => { + if (socket.uType == 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.ip !== 'string' && typeof data.hash !== 'string') { + server.reply({ + cmd: 'warn', + text: "hash:'targethash' or ip:'1.2.3.4' is required" + }, socket); + + return; + } + + let mode, target; + + if (typeof data.ip === 'string') { + mode = 'ip'; + target = data.ip; + } else { + mode = 'hash'; + target = data.hash; + } + + server._police.pardon(target); + + if (mode === 'ip') { + target = server.getSocketHash(target); + } + + console.log(`${socket.nick} [${socket.trip}] unbanned ${target} in ${socket.channel}`); + + server.reply({ + cmd: 'info', + text: `Unbanned ${target}` + }, socket); + + server.broadcast({ + cmd: 'info', + text: `${socket.nick} unbanned: ${target}` + }, { uType: 'mod' }); + + core.managers.stats.decrement('users-banned'); +}; + +exports.info = { + name: 'unban', + usage: 'unban {[ip || hash]}', + description: 'Removes target ip from the ratelimiter' +}; \ No newline at end of file -- cgit v1.2.1