MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / lookup

Method lookup

app/src/API/Handlers/NetworkHandler.cpp:261–281  ·  view source on GitHub ↗

* @brief Perform DNS lookup for a hostname */

Source from the content-addressed store, hash-verified

259 * @brief Perform DNS lookup for a hostname
260 */
261API::CommandResponse API::Handlers::NetworkHandler::lookup(const QString& id,
262 const QJsonObject& params)
263{
264 if (!params.contains(QStringLiteral("host"))) {
265 return CommandResponse::makeError(
266 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: host"));
267 }
268
269 const QString host = params.value(QStringLiteral("host")).toString();
270 if (host.isEmpty()) {
271 return CommandResponse::makeError(
272 id, ErrorCode::InvalidParam, QStringLiteral("Host cannot be empty"));
273 }
274
275 IO::ConnectionManager::instance().network()->lookup(host);
276
277 QJsonObject result;
278 result[QStringLiteral("host")] = host;
279 result[QStringLiteral("lookupStarted")] = true;
280 return CommandResponse::makeSuccess(id, result);
281}
282
283//--------------------------------------------------------------------------------------------------
284// Getters

Callers

nothing calls this directly

Calls 4

isEmptyMethod · 0.80
networkMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected