* @brief Perform DNS lookup for a hostname */
| 259 | * @brief Perform DNS lookup for a hostname |
| 260 | */ |
| 261 | API::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 |