ser:服务端接收大量无效数据时踢出客户端。

This commit is contained in:
2025-11-15 17:26:09 +08:00
parent de792bb68f
commit 7a69db774d
3 changed files with 13 additions and 5 deletions

View File

@@ -103,6 +103,12 @@ void Server::onReadyRead()
}
if (client) {
if (client->buffer.size() > MAX_INVALID_PACKET_SIZE) {
auto mg = QString("Client %1 buffer size exceeded, XXXXX...").arg(client->id);
qWarning() << mg;
socket->disconnectFromHost();
return;
}
client->buffer.append(socket->readAll());
processClientData(client);
}
@@ -143,7 +149,7 @@ bool Server::sendWithFlowCheck(QTcpSocket* fsoc, QTcpSocket* tsoc, QSharedPointe
if (flowBackCount_[fsoc->property("clientId").toString()] > FLOW_BACK_MULTIPLE) {
auto level = getBlockLevel(tsoc);
flowLimit(fsoc, level);
//qDebug() << "Flow back count exceeded, block level:" << level;
// qDebug() << "Flow back count exceeded, block level:" << level;
}
flowBackCount_[fsoc->property("clientId").toString()]++;
return sendData(tsoc, frame);