Skip to content
Snippets Groups Projects
Unverified Commit 1a3ef4f6 authored by Diego Sampaio's avatar Diego Sampaio
Browse files

revert: rate limiter bindEnvironment

parent 7ebbfd1f
No related branches found
No related tags found
No related merge requests found
...@@ -30,12 +30,12 @@ const names = new Set( ...@@ -30,12 +30,12 @@ const names = new Set(
// Override the addRule to save new names added after this point // Override the addRule to save new names added after this point
const { addRule } = DDPRateLimiter; const { addRule } = DDPRateLimiter;
DDPRateLimiter.addRule = Meteor.bindEnvironment((matcher, calls, time, callback) => { DDPRateLimiter.addRule = (matcher, calls, time, callback) => {
if (matcher && typeof matcher.name === 'string') { if (matcher && typeof matcher.name === 'string') {
names.add(matcher.name); names.add(matcher.name);
} }
return addRule.call(DDPRateLimiter, matcher, calls, time, callback); return addRule.call(DDPRateLimiter, matcher, calls, time, callback);
}); };
const { _increment } = DDPRateLimiter; const { _increment } = DDPRateLimiter;
DDPRateLimiter._increment = function (input) { DDPRateLimiter._increment = function (input) {
...@@ -151,7 +151,7 @@ const messages = { ...@@ -151,7 +151,7 @@ const messages = {
Connection_By_Method: 'connectionId per method', Connection_By_Method: 'connectionId per method',
}; };
const reconfigureLimit = (name, rules, factor = 1) => { const reconfigureLimit = Meteor.bindEnvironment((name, rules, factor = 1) => {
if (ruleIds[name + factor]) { if (ruleIds[name + factor]) {
DDPRateLimiter.removeRule(ruleIds[name + factor]); DDPRateLimiter.removeRule(ruleIds[name + factor]);
} }
...@@ -166,7 +166,7 @@ const reconfigureLimit = (name, rules, factor = 1) => { ...@@ -166,7 +166,7 @@ const reconfigureLimit = (name, rules, factor = 1) => {
settings.get(`DDP_Rate_Limit_${name}_Interval_Time`) * factor, settings.get(`DDP_Rate_Limit_${name}_Interval_Time`) * factor,
callback(`limit by ${messages[name]}`, name), callback(`limit by ${messages[name]}`, name),
); );
}; });
const configIP = _.debounce(() => { const configIP = _.debounce(() => {
reconfigureLimit('IP', { reconfigureLimit('IP', {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment