Added rate limiting logging and an error page for hitting the rate limit on opening characters
This commit is contained in:
8
rpg-docs/server/lib/logRateError.js
Normal file
8
rpg-docs/server/lib/logRateError.js
Normal 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}`
|
||||
);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user