aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/core
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/core
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/core/rateLimiter.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/server/src/core/rateLimiter.js b/server/src/core/rateLimiter.js
index f5c739b..0d94ef2 100644
--- a/server/src/core/rateLimiter.js
+++ b/server/src/core/rateLimiter.js
@@ -18,6 +18,7 @@ class Police {
this._records = {};
this._halflife = 30000; // ms
this._threshold = 25;
+ this._hashes = [];
}
/**
@@ -76,12 +77,11 @@ class Police {
*
* @memberof Police
*/
- arrest (id) {
- var record = this.search(id);
+ arrest (id, hash) {
+ let record = this.search(id);
- if (record) {
- record.arrested = true;
- }
+ record.arrested = true;
+ this._hashes[hash] = id;
}
/**
@@ -93,14 +93,12 @@ class Police {
* @memberof Police
*/
pardon (id) {
- var record = this.search(id);
-
- if (record) {
- record.arrested = false;
- return true;
+ if (typeof this._hashes[id] !== 'undefined') {
+ id = this._hashes[id];
}
-
- return false;
+
+ let record = this.search(id);
+ record.arrested = false;
}
}