fix(backend): 無制限にストリーミングのチャンネルに接続できる問題を修正

This commit is contained in:
syuilo 2024-08-17 09:30:03 +09:00 committed by dakkar
parent 6d3f9503ed
commit 76bbc10aa1

View file

@ -20,6 +20,8 @@ import type Channel from './channel.js';
import { LoggerService } from '@/core/LoggerService.js'; import { LoggerService } from '@/core/LoggerService.js';
import type Logger from '@/logger.js'; import type Logger from '@/logger.js';
const MAX_CHANNELS_PER_CONNECTION = 32;
/** /**
* Main stream connection * Main stream connection
*/ */
@ -283,6 +285,10 @@ export default class Connection {
*/ */
@bindThis @bindThis
public connectChannel(id: string, params: any, channel: string, pong = false) { public connectChannel(id: string, params: any, channel: string, pong = false) {
if (this.channels.length >= MAX_CHANNELS_PER_CONNECTION) {
return;
}
const channelService = this.channelsService.getChannelService(channel); const channelService = this.channelsService.getChannelService(channel);
if (channelService.requireCredential && this.user == null) { if (channelService.requireCredential && this.user == null) {