From 7d1291b9f06f27b3e1bad5906ab153bd5ef9c983 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 3 Nov 2024 22:51:14 +0100 Subject: [PATCH] RequestServer: Implement the ResolveOnly EnsureConnection level --- Services/RequestServer/ConnectionFromClient.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Services/RequestServer/ConnectionFromClient.cpp b/Services/RequestServer/ConnectionFromClient.cpp index 74e0a21eaa8..9b0502cfcaf 100644 --- a/Services/RequestServer/ConnectionFromClient.cpp +++ b/Services/RequestServer/ConnectionFromClient.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -598,7 +599,16 @@ void ConnectionFromClient::ensure_connection(URL::URL const& url, ::RequestServe } if (cache_level == CacheLevel::ResolveOnly) { - dbgln("FIXME: EnsureConnection: Implement ResolveOnly cache level"); + [[maybe_unused]] auto promise = m_resolver->dns.lookup(url.serialized_host().value().to_byte_string(), DNS::Messages::Class::IN, Array { DNS::Messages::ResourceType::A, DNS::Messages::ResourceType::AAAA }.span()); + if constexpr (REQUESTSERVER_DEBUG) { + Core::ElapsedTimer timer; + timer.start(); + promise->when_resolved([url, timer](auto const& results) -> ErrorOr { + dbgln("ensure_connection::ResolveOnly({}) OK {} entrie(s) in {}ms", url, results->cached_addresses().size(), timer.elapsed()); + return {}; + }); + promise->when_rejected([url](auto const&) { dbgln("ensure_connection::ResolveOnly({}) rejected", url); }); + } } }