mirror of https://gitlab.com/litecord/litecord.git
gateway.websocket: add _ws.session ratelimit
This commit is contained in:
parent
1f5f736a8e
commit
c710ad5aaf
|
|
@ -414,6 +414,10 @@ class GatewayWebsocket:
|
||||||
await self.invalidate_session(False)
|
await self.invalidate_session(False)
|
||||||
raise WebsocketClose(4009, 'You are being ratelimited.')
|
raise WebsocketClose(4009, 'You are being ratelimited.')
|
||||||
|
|
||||||
|
if self._check_ratelimit('session', user_id):
|
||||||
|
await self.invalidate_session(False)
|
||||||
|
raise WebsocketClose(4004, 'Websocket Session Ratelimit reached.')
|
||||||
|
|
||||||
async def handle_2(self, payload: Dict[str, Any]):
|
async def handle_2(self, payload: Dict[str, Any]):
|
||||||
"""Handle the OP 2 Identify packet."""
|
"""Handle the OP 2 Identify packet."""
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ RATELIMITS = {
|
||||||
'_ws.connect': Ratelimit(1, 5),
|
'_ws.connect': Ratelimit(1, 5),
|
||||||
'_ws.presence': Ratelimit(5, 60),
|
'_ws.presence': Ratelimit(5, 60),
|
||||||
'_ws.messages': Ratelimit(120, 60),
|
'_ws.messages': Ratelimit(120, 60),
|
||||||
|
|
||||||
|
# 1000 / 4h for new session issuing
|
||||||
|
'_ws.session': Ratelimit(1000, 14400)
|
||||||
}
|
}
|
||||||
|
|
||||||
class RatelimitManager:
|
class RatelimitManager:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue