|
|
|
@ -5,9 +5,8 @@ import { ThrottlerException, ThrottlerGuard } from '@nestjs/throttler'
@@ -5,9 +5,8 @@ import { ThrottlerException, ThrottlerGuard } from '@nestjs/throttler'
|
|
|
|
|
export class WsThrottlerGuard extends ThrottlerGuard { |
|
|
|
|
async handleRequest(context: ExecutionContext, limit: number, ttl: number): Promise<boolean> { |
|
|
|
|
const client = context.switchToWs().getClient() |
|
|
|
|
console.log('conn', client.conn) |
|
|
|
|
console.log('socket', client._socket) |
|
|
|
|
const ip = client._socket.remoteAddress |
|
|
|
|
|
|
|
|
|
const ip = client.conn.remoteAddress |
|
|
|
|
const key = this.generateKey(context, ip) |
|
|
|
|
const { totalHits } = await this.storageService.increment(key, ttl) |
|
|
|
|
console.log('ip', ip, totalHits) |
|
|
|
|