Protect Boblight server against clients sending too much data

Former-commit-id: f3a575f71425da25fbaad68c48dcec746a50def2
This commit is contained in:
johan
2013-11-09 10:33:16 +01:00
parent 39b7f1d52e
commit c77f45f221
2 changed files with 11 additions and 0 deletions

View File

@@ -67,6 +67,13 @@ void BoblightClientConnection::readData()
// handle message
handleMessage(message);
// drop messages if the buffer is too full
if (_receiveBuffer.size() > 100*1024)
{
std::cout << "Boblight server drops messages" << std::endl;
_receiveBuffer.clear();
}
// try too look up '\n' again
bytes = _receiveBuffer.indexOf('\n') + 1;
}
@@ -183,6 +190,7 @@ void BoblightClientConnection::handleMessage(const QString & message)
{
_hyperion->setColors(_priority, _ledColors, -1);
}
return;
}
}