diff --git a/Libraries/LibDNS/Resolver.h b/Libraries/LibDNS/Resolver.h index 2a7747dba573..316fd47ee89c 100644 --- a/Libraries/LibDNS/Resolver.h +++ b/Libraries/LibDNS/Resolver.h @@ -126,6 +126,20 @@ class Resolver { : m_pending_lookups(make>()) , m_create_socket(move(create_socket)) { + m_cache.with_write_locked([&](auto& cache) { + auto add_v4v6_entry = [&cache](StringView name_string, IPv4Address v4, IPv6Address v6) { + auto name = Messages::DomainName::from_string(name_string); + auto ptr = make_ref_counted(name); + ptr->will_add_record_of_type(Messages::ResourceType::A); + ptr->will_add_record_of_type(Messages::ResourceType::AAAA); + cache.set(name_string, ptr); + + ptr->add_record({ .name = {}, .type = Messages::ResourceType::A, .class_ = Messages::Class::IN, .ttl = 0, .record = Messages::Records::A { v4 }, .raw = {} }); + ptr->add_record({ .name = {}, .type = Messages::ResourceType::AAAA, .class_ = Messages::Class::IN, .ttl = 0, .record = Messages::Records::AAAA { v6 }, .raw = {} }); + }; + + add_v4v6_entry("localhost"sv, { 127, 0, 0, 1 }, IPv6Address::loopback()); + }); } NonnullRefPtr> when_socket_ready()