martinzink commented on code in PR #1510: URL: https://github.com/apache/nifi-minifi-cpp/pull/1510#discussion_r1115577667
########## 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: You are right, removed it in https://github.com/apache/nifi-minifi-cpp/pull/1510/commits/4bb1c8fc0d9c456613ef49a2bdc33762b2caf3d5#diff-f0907daecdf93b300b66d2224cf21f677c966e82a58b738132721daf27852c26L23 ########## 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: Good idea, I've changed it in https://github.com/apache/nifi-minifi-cpp/pull/1510/commits/4bb1c8fc0d9c456613ef49a2bdc33762b2caf3d5#diff-f84ab4bed4b25e41f8cb612c6444720295b6050fdb70720ada4aea04b389565aR201 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
