szaszm commented on code in PR #1510: URL: https://github.com/apache/nifi-minifi-cpp/pull/1510#discussion_r1113463174
########## extensions/expression-language/Expression.cpp: ########## @@ -183,6 +187,20 @@ Value expr_ip(const std::vector<Value>& /*args*/) { return {}; } +Value expr_reverseDnsLookup(const std::vector<Value>& args) { + std::string ip_address_str = args[0].asString(); + + std::chrono::steady_clock::duration timeout_duration = 5s; + if (args.size() > 1) { + timeout_duration = std::chrono::milliseconds(args[1].asUnsignedLong()); + } + + return utils::net::addressFromString(ip_address_str) + | utils::flatMap([timeout_duration](const auto& ip_address) { return utils::net::reverseDnsLookup(ip_address, timeout_duration);}) + | utils::map([](const auto& hostname)-> Value { return Value(hostname); }) + | utils::valueOrElse([&](std::error_code error_code) { throw std::runtime_error(error_code.message());}); Review Comment: I'd throw a `std::system_error` instead. It's meant to wrap an error code, as opposed to the more general `std::runtime_error`. ########## libminifi/include/utils/net/DNS.h: ########## @@ -15,13 +15,16 @@ * limitations under the License. */ #pragma once +#include <chrono> #include <memory> #include <string> #include <string_view> #include <system_error> +#include <vector> Review Comment: I don't see the need to include vector. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org