Add ratelimit for reset votes
This commit is contained in:
@@ -21,6 +21,7 @@ export class User {
|
|||||||
LoginRateLimit : RateLimiter;
|
LoginRateLimit : RateLimiter;
|
||||||
RenameRateLimit : RateLimiter;
|
RenameRateLimit : RateLimiter;
|
||||||
TurnRateLimit : RateLimiter;
|
TurnRateLimit : RateLimiter;
|
||||||
|
VoteRateLimit : RateLimiter;
|
||||||
constructor(ws : WebSocket, ip : IPData, config : IConfig, username? : string, node? : string) {
|
constructor(ws : WebSocket, ip : IPData, config : IConfig, username? : string, node? : string) {
|
||||||
this.IP = ip;
|
this.IP = ip;
|
||||||
this.connectedToNode = false;
|
this.connectedToNode = false;
|
||||||
@@ -48,6 +49,8 @@ export class User {
|
|||||||
this.LoginRateLimit.on('limit', () => this.closeConnection());
|
this.LoginRateLimit.on('limit', () => this.closeConnection());
|
||||||
this.TurnRateLimit = new RateLimiter(5, 3);
|
this.TurnRateLimit = new RateLimiter(5, 3);
|
||||||
this.TurnRateLimit.on('limit', () => this.closeConnection());
|
this.TurnRateLimit.on('limit', () => this.closeConnection());
|
||||||
|
this.VoteRateLimit = new RateLimiter(3, 3);
|
||||||
|
this.VoteRateLimit.on('limit', () => this.closeConnection());
|
||||||
}
|
}
|
||||||
assignGuestName(existingUsers : string[]) : string {
|
assignGuestName(existingUsers : string[]) : string {
|
||||||
var username;
|
var username;
|
||||||
|
|||||||
@@ -272,6 +272,7 @@ export default class WSServer {
|
|||||||
case "vote":
|
case "vote":
|
||||||
if (!client.connectedToNode) return;
|
if (!client.connectedToNode) return;
|
||||||
if (msgArr.length !== 2) return;
|
if (msgArr.length !== 2) return;
|
||||||
|
if (!client.VoteRateLimit.request()) return;
|
||||||
switch (msgArr[1]) {
|
switch (msgArr[1]) {
|
||||||
case "1":
|
case "1":
|
||||||
if (!this.voteInProgress) {
|
if (!this.voteInProgress) {
|
||||||
|
|||||||
Reference in New Issue
Block a user