Add IP and user ID to connection close message
This commit is contained in:
parent
c5f7dcbb7e
commit
3dd993a76a
2 changed files with 6 additions and 2 deletions
|
@ -159,7 +159,7 @@ export class StreamingApiServerService {
|
|||
this.cacheService,
|
||||
this.channelFollowingService,
|
||||
this.loggerService,
|
||||
user, app,
|
||||
user, app, requestIp,
|
||||
rateLimiter,
|
||||
);
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ export default class Connection {
|
|||
|
||||
user: MiUser | null | undefined,
|
||||
token: MiAccessToken | null | undefined,
|
||||
private ip: string,
|
||||
rateLimiter: () => Promise<boolean>,
|
||||
) {
|
||||
if (user) this.user = user;
|
||||
|
@ -127,7 +128,10 @@ export default class Connection {
|
|||
if (shouldRateLimit) return;
|
||||
if (this.closingConnection) return;
|
||||
} else {
|
||||
this.logger.warn('Closing a connection due to an excessive influx of messages.');
|
||||
let connectionInfo = `IP ${this.ip}`;
|
||||
if (this.user) connectionInfo += `, user ID ${this.user.id}`;
|
||||
|
||||
this.logger.warn(`Closing a connection (${connectionInfo}) due to an excessive influx of messages.`);
|
||||
this.closingConnection = true;
|
||||
this.wsConnection.close(1008, 'Please stop spamming the streaming API.');
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue