aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2018-03-14 07:22:23 +0100
committermarzavec <admin@marzavec.com>2018-03-14 07:22:23 +0100
commitaa33c86af09afc524833e4ff5f5764c2c3be553c (patch)
treebb00af3dd44a97f33002fb9a9db28f6f28ee1cec /server/src/commands
parentStreamlined modules, server tweaks, better feedback (diff)
downloadhackchat-aa33c86af09afc524833e4ff5f5764c2c3be553c.tar.gz
hackchat-aa33c86af09afc524833e4ff5f5764c2c3be553c.zip
Added unban by hash
Diffstat (limited to '')
-rw-r--r--server/src/commands/mod/ban.js5
-rw-r--r--server/src/commands/mod/unban.js38
2 files changed, 24 insertions, 19 deletions
diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js
index 5ee77b6..19f297a 100644
--- a/server/src/commands/mod/ban.js
+++ b/server/src/commands/mod/ban.js
@@ -38,7 +38,8 @@ exports.run = async (core, server, socket, data) => {
}
// TODO unban by hash
- server._police.arrest(badClient.remoteAddress);
+ let clientHash = server.getSocketHash(badClient);
+ server._police.arrest(badClient.remoteAddress, clientHash);
console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`);
@@ -49,7 +50,7 @@ exports.run = async (core, server, socket, data) => {
server.broadcast({
cmd: 'info',
- text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${server.getSocketHash(badClient)}`
+ text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${clientHash}`
}, { uType: 'mod' });
badClient.close();
diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js
index ee028d2..2406644 100644
--- a/server/src/commands/mod/unban.js
+++ b/server/src/commands/mod/unban.js
@@ -10,44 +10,48 @@ exports.run = async (core, server, socket, data) => {
return;
}
- if (typeof data.ip !== 'string') {
+ 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 ip = data.ip;
- let hash = data.hash; // TODO unban by hash
+ let mode, target;
- // TODO unban by hash
- let recordFound = server._police.pardon(data.ip);
+ if (typeof data.ip === 'string') {
+ mode = 'ip';
+ target = data.ip;
+ } else {
+ mode = 'hash';
+ target = data.hash;
+ }
- if (!recordFound) {
- server.reply({
- cmd: 'warn',
- text: 'Could not find target in records'
- }, socket);
+ server._police.pardon(target);
- return;
+ if (mode === 'ip') {
+ target = server.getSocketHash(target);
}
- console.log(`${socket.nick} [${socket.trip}] unbanned ${/*hash || */ip} in ${socket.channel}`);
+ console.log(`${socket.nick} [${socket.trip}] unbanned ${target} in ${socket.channel}`);
server.reply({
cmd: 'info',
- text: `${socket.nick} unbanned a userhash: ${server.getSocketHash(ip)}`
+ text: `Unbanned ${target}`
}, socket);
server.broadcast({
cmd: 'info',
- text: `${socket.nick} unbanned a userhash: ${server.getSocketHash(ip)}`
+ text: `${socket.nick} unbanned: ${target}`
}, { uType: 'mod' });
core.managers.stats.decrement('users-banned');
};
-exports.requiredData = ['ip'];
-
exports.info = {
name: 'unban',
- usage: 'unban {ip}',
+ usage: 'unban {[ip || hash]}',
description: 'Removes target ip from the ratelimiter'
};