* @brief Processes a non-JSON raw line from the buffer. */
| 1131 | * @brief Processes a non-JSON raw line from the buffer. |
| 1132 | */ |
| 1133 | void API::Server::processRawLine(QTcpSocket* socket, ConnectionState& state, const QByteArray& line) |
| 1134 | { |
| 1135 | Q_ASSERT(socket); |
| 1136 | Q_ASSERT(!line.isEmpty()); |
| 1137 | |
| 1138 | if (line.size() > kMaxApiRawBytes) { |
| 1139 | qWarning() << "[API] Raw line size limit exceeded:" << state.peerAddress << ":" |
| 1140 | << state.peerPort << "- Line size:" << line.size() << "- Limit:" << kMaxApiRawBytes |
| 1141 | << "- Disconnecting client"; |
| 1142 | |
| 1143 | sendResponseToSocket( |
| 1144 | socket, |
| 1145 | CommandResponse::makeError( |
| 1146 | QString(), ErrorCode::ExecutionError, QStringLiteral("Raw payload exceeds size limit")) |
| 1147 | .toJsonBytes()); |
| 1148 | |
| 1149 | auto* worker = static_cast<ServerWorker*>(m_worker); |
| 1150 | QMetaObject::invokeMethod( |
| 1151 | worker, "disconnectSocket", Qt::QueuedConnection, Q_ARG(QTcpSocket*, socket)); |
| 1152 | return; |
| 1153 | } |
| 1154 | |
| 1155 | if (!authorizeDeviceWrite()) { |
| 1156 | sendResponseToSocket(socket, |
| 1157 | CommandResponse::makeError(QString(), |
| 1158 | ErrorCode::ExecutionError, |
| 1159 | QStringLiteral("Device write denied by user")) |
| 1160 | .toJsonBytes()); |
| 1161 | return; |
| 1162 | } |
| 1163 | |
| 1164 | const qint64 written = IO::ConnectionManager::instance().writeData(line); |
| 1165 | if (written < 0) [[unlikely]] |
| 1166 | qWarning() << "[API] writeData() failed for raw line" |
| 1167 | << "-- data not sent to device"; |
| 1168 | } |
| 1169 | |
| 1170 | //-------------------------------------------------------------------------------------------------- |
| 1171 | // Server: data reception & dispatch |
nothing calls this directly
no test coverage detected