mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:35:23 +00:00
UI: ControlManager: Improve log about bad control requests
This commit is contained in:
parent
baaa249796
commit
cbe58b755e
@ -51,8 +51,6 @@ ControlWorker *ControlManager::newServiceClient(QObject *parent) const
|
||||
w->setupForAsync();
|
||||
w->setIsServiceClient(true);
|
||||
|
||||
connect(w, &ControlWorker::disconnected, this,
|
||||
[&] { logWarning() << "Server disconnected" << w->errorString(); });
|
||||
connect(w, &ControlWorker::requestReady, this, &ControlManager::processRequest);
|
||||
|
||||
if (!w->connectToServer(getServerName(true))) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QLocalSocket>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
namespace {
|
||||
|
||||
@ -223,12 +224,20 @@ bool ControlWorker::readRequest()
|
||||
|
||||
bool ControlWorker::readRequestHeader()
|
||||
{
|
||||
if (socket()->read((char *) &m_requestHeader, sizeof(RequestHeader)) != sizeof(RequestHeader))
|
||||
const int headerSize = socket()->read((char *) &m_requestHeader, sizeof(RequestHeader));
|
||||
if (headerSize != sizeof(RequestHeader)) {
|
||||
qWarning() << "Bad request header:"
|
||||
<< "size=" << headerSize;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_requestHeader.command() == Control::CommandNone
|
||||
|| m_requestHeader.dataSize() > dataMaxSize)
|
||||
|| m_requestHeader.dataSize() > dataMaxSize) {
|
||||
qWarning() << "Bad request:"
|
||||
<< "command=" << m_requestHeader.command()
|
||||
<< "size=" << m_requestHeader.dataSize();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user