mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibDNS: Add a default entry for localhost
In the future, we may want to parse /etc/hosts (or equivalent) into the cache; this commit only adds localhost to make the normal workflow work.
This commit is contained in:
parent
3bcd91b109
commit
c5afe58540
Notes:
github-actions[bot]
2024-11-20 20:43:50 +00:00
Author: https://github.com/alimpfard Commit: https://github.com/LadybirdBrowser/ladybird/commit/c5afe585406 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2111 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 14 additions and 0 deletions
|
@ -126,6 +126,20 @@ public:
|
||||||
: m_pending_lookups(make<RedBlackTree<u16, PendingLookup>>())
|
: m_pending_lookups(make<RedBlackTree<u16, PendingLookup>>())
|
||||||
, m_create_socket(move(create_socket))
|
, 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<LookupResult>(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<Core::Promise<Empty>> when_socket_ready()
|
NonnullRefPtr<Core::Promise<Empty>> when_socket_ready()
|
||||||
|
|
Loading…
Reference in a new issue