Added rate limiting logging and an error page for hitting the rate limit on opening characters

This commit is contained in:
Thaum Rystra
2018-04-02 14:26:55 +02:00
parent 164ba78c81
commit 742b26b0de
6 changed files with 79 additions and 7 deletions

View File

@@ -0,0 +1,8 @@
logRateError = function(reply, ruleInput){
// reply = {allowed, timeToReset, numInvocationsLeft}
// ruleInput = {userId, clientAddress, type, name, connectionId}
console.log(
`Limit hit for ${ruleInput.type} "${ruleInput.name}" ` +
`by user ${ruleInput.userId} from ${ruleInput.clientAddress}`
);
}

View File

@@ -38,9 +38,13 @@ Meteor.publish("singleCharacter", function(characterId){
DDPRateLimiter.addRule({
name: "singleCharacter",
type: "subscription",
userId(){ return true; },
userId: null,
connectionId(){ return true; },
}, 8, 5000);
}, 8, 10000, function(reply, ruleInput){
if(!reply.allowed){
logRateError(reply, ruleInput);
}
});
Meteor.publish("singleCharacterName", function(characterId){
userId = this.userId;