Truly independent web browser
LibDNS+LibHTTP+RequestServer: Resolve a proxy’s host with our resolver
sideshowbarker09f210798c23
diff --git a/Libraries/LibDNS/Resolver.h b/Libraries/LibDNS/Resolver.hindex 098b28361ee..93f985c57a7 100644--- a/Libraries/LibDNS/Resolver.h+++ b/Libraries/LibDNS/Resolver.h@@ -187,6 +187,9 @@ public:struct LookupOptions {bool validate_dnssec_locally { false };+ // Asks the system resolver for AAAA records even when no global IPv6 route exists, as a host on the local+ // network may still be reachable over IPv6.+ bool query_aaaa_without_global_ipv6 { false };static LookupOptions default_() { return {}; }};@@ -447,7 +450,7 @@ public:// platforms (mDNSResponder never suppresses multicast queries). Like Chromium's host cache, which keys a// lookup without AAAA apart from one with it, a cached result without AAAA only serves while IPv6 stays// unreachable.- auto skips_aaaa = uses_system_resolver && !is_link_local_name+ auto skips_aaaa = uses_system_resolver && !is_link_local_name && !options.query_aaaa_without_global_ipv6&& desired_types.contains_slow(Messages::ResourceType::A)&& desired_types.contains_slow(Messages::ResourceType::AAAA)&& !is_ipv6_globally_reachable();diff --git a/Libraries/LibHTTP/Proxy.cpp b/Libraries/LibHTTP/Proxy.cppindex 87d18fd19cc..d851a51bd45 100644--- a/Libraries/LibHTTP/Proxy.cpp+++ b/Libraries/LibHTTP/Proxy.cpp@@ -73,6 +73,10 @@ Optional<Proxy> Proxy::parse(StringView string)proxy.host = string.to_byte_string().to_lowercase();}+ // libcurl decodes a percent-encoded host, e.g. %6cocalhost, before it looks the host up. An IPv6 address keeps its+ // zone, e.g. %25eth0, as written.+ if (!proxy.host.contains(':'))+ proxy.host = URL::percent_decode(proxy.host).to_lowercase();if (proxy.host.is_empty())return {};diff --git a/Libraries/LibHTTP/Proxy.h b/Libraries/LibHTTP/Proxy.hindex b8f3d44efc0..28625490f1a 100644--- a/Libraries/LibHTTP/Proxy.h+++ b/Libraries/LibHTTP/Proxy.h@@ -32,6 +32,8 @@ struct Proxy {// For CURLOPT_PROXY.ByteString to_curl_url() const;+ bool operator==(Proxy const&) const = default;+Type type { Type::HTTP };ByteString host;u16 port { 0 };diff --git a/Services/RequestServer/ConnectionFromClient.cpp b/Services/RequestServer/ConnectionFromClient.cppindex de13799a90f..822c16bdb5a 100644--- a/Services/RequestServer/ConnectionFromClient.cpp+++ b/Services/RequestServer/ConnectionFromClient.cpp@@ -627,8 +627,25 @@ void ConnectionFromClient::fetch_aia_intermediate(Badge<Request>, ByteString conauto fetch_url = parsed->serialize().to_byte_string();auto weak_self = make_weak_ptr<ConnectionFromClient>();- // Avoid leaking hostnames resolved by the proxy.auto proxy = proxy_configuration().proxy_for(*parsed).copy();+ resolve_proxy_host(proxy, [weak_self, url, fetch_url, host, port, proxy](ErrorOr<void> result) mutable {+ auto self = weak_self.strong_ref();+ if (!self)+ return;+ if (result.is_error()) {+ dbgln_if(REQUESTSERVER_DEBUG, "AIA: Proxy lookup failed for {}: {}", url, result.error());+ self->abandon_aia_lookup(url);+ return;+ }+ self->look_up_aia_host(url, fetch_url, host, port, move(proxy));+ });+}++void ConnectionFromClient::look_up_aia_host(ByteString const& url, ByteString const& fetch_url, ByteString const& host, u16 port, Optional<HTTP::Proxy> proxy)+{+ auto weak_self = make_weak_ptr<ConnectionFromClient>();++ // Avoid leaking hostnames resolved by the proxy.if (proxy.has_value() && proxy->resolves_hostnames()) {start_aia_fetch(url, fetch_url, move(proxy), {});return;@@ -703,11 +720,14 @@ void ConnectionFromClient::start_aia_fetch(ByteString const& url, ByteString conset_option(CURLOPT_WRITEDATA, fetch.ptr());set_option(CURLOPT_PROXY, proxy.has_value() ? proxy->to_curl_url().characters() : "");- if (resolve_entry.has_value()) {- if (curl_slist* resolve_list = curl_slist_append(nullptr, resolve_entry->characters())) {- set_option(CURLOPT_RESOLVE, resolve_list);- fetch->resolve_list = resolve_list;- }+ curl_slist* resolve_list = nullptr;+ for (auto const& entry : { move(resolve_entry), curl_resolve_entry_for_proxy(proxy) }) {+ if (entry.has_value())+ resolve_list = curl_slist_append(resolve_list, entry->characters());+ }+ if (resolve_list) {+ set_option(CURLOPT_RESOLVE, resolve_list);+ fetch->resolve_list = resolve_list;}auto result = curl_multi_add_handle(m_fetch_curl.handle, easy_handle);@@ -978,8 +998,27 @@ void ConnectionFromClient::connect_websocket(u64 websocket_id, URL::URL url, Bytreturn;}- // Avoid leaking hostnames resolved by the proxy.auto proxy = proxy_configuration().proxy_for(url).copy();+ resolve_proxy_host(proxy, [weak_self, websocket_id, url = move(url), origin = move(origin), protocols = move(protocols), extensions = move(extensions), additional_request_headers = move(additional_request_headers), proxy](ErrorOr<void> result) mutable {+ auto self = weak_self.strong_ref();+ if (!self)+ return;+ if (result.is_error()) {+ dbgln("WebSocketConnect: Proxy lookup failed: {}", result.error());+ if (self->m_pending_websockets.remove(websocket_id))+ self->fail_websocket(websocket_id, Requests::WebSocket::Error::CouldNotEstablishConnection);+ return;+ }+ self->look_up_websocket_host(websocket_id, move(url), move(origin), move(protocols), move(extensions), move(additional_request_headers), move(proxy));+ });+}++void ConnectionFromClient::look_up_websocket_host(u64 websocket_id, URL::URL url, ByteString origin, Vector<ByteString> protocols, Vector<ByteString> extensions, Vector<HTTP::Header> additional_request_headers, Optional<HTTP::Proxy> proxy)+{+ auto host = url.serialized_host().to_byte_string();+ auto weak_self = make_weak_ptr<ConnectionFromClient>();++ // Avoid leaking hostnames resolved by the proxy.if (proxy.has_value() && proxy->resolves_hostnames()) {if (m_pending_websockets.remove(websocket_id))open_websocket(websocket_id, move(url), move(origin), move(protocols), move(extensions), move(additional_request_headers), move(proxy), nullptr);diff --git a/Services/RequestServer/ConnectionFromClient.h b/Services/RequestServer/ConnectionFromClient.hindex 59d988647fc..7b700b7750f 100644--- a/Services/RequestServer/ConnectionFromClient.h+++ b/Services/RequestServer/ConnectionFromClient.h@@ -112,6 +112,7 @@ private:size_t websocket_count() const;size_t total_websocket_count() const;void connect_websocket(u64 websocket_id, URL::URL, ByteString origin, Vector<ByteString> protocols, Vector<ByteString> extensions, Vector<HTTP::Header> request_headers);+ void look_up_websocket_host(u64 websocket_id, URL::URL, ByteString origin, Vector<ByteString> protocols, Vector<ByteString> extensions, Vector<HTTP::Header> additional_request_headers, Optional<HTTP::Proxy>);void open_websocket(u64 websocket_id, URL::URL, ByteString origin, Vector<ByteString> protocols, Vector<ByteString> extensions, Vector<HTTP::Header> additional_request_headers, Optional<HTTP::Proxy>, RefPtr<DNS::LookupResult const>);IsPrivate m_is_private { IsPrivate::No };@@ -148,6 +149,7 @@ private:HashMap<u64, NonnullOwnPtr<Request>> m_active_requests;HashMap<u64, NonnullOwnPtr<Request>> m_active_revalidation_requests;+ void look_up_aia_host(ByteString const& url, ByteString const& fetch_url, ByteString const& host, u16 port, Optional<HTTP::Proxy>);void start_aia_fetch(ByteString const& url, ByteString const& fetch_url, Optional<HTTP::Proxy>, Optional<ByteString> resolve_entry);void abandon_aia_lookup(ByteString const& url);diff --git a/Services/RequestServer/Request.cpp b/Services/RequestServer/Request.cppindex 618c9134c60..27b6ece7cbf 100644--- a/Services/RequestServer/Request.cpp+++ b/Services/RequestServer/Request.cpp@@ -1283,8 +1283,24 @@ void Request::handle_dns_lookup_state()return;}- // Avoid leaking hostnames resolved by the proxy.m_proxy = proxy_configuration().proxy_for(m_url).copy();+ // The proxy configuration can change while a lookup is pending, so resolve again for a different proxy.+ if (!m_proxy_host_resolved || m_resolved_proxy != m_proxy) {+ resolve_proxy_host(m_proxy, weak_callback(*this, [proxy = m_proxy](auto& self, ErrorOr<void> result) {+ if (result.is_error()) {+ dbgln("Request::handle_dns_lookup_state: Proxy lookup failed: {}", result.error());+ self.m_network_error = Requests::NetworkError::UnableToResolveProxy;+ self.transition_to_state(State::Error);+ return;+ }+ self.m_proxy_host_resolved = true;+ self.m_resolved_proxy = proxy;+ self.handle_dns_lookup_state();+ }));+ return;+ }++ // Avoid leaking hostnames resolved by the proxy.if (m_proxy.has_value() && m_proxy->resolves_hostnames()) {m_dns_result = nullptr;continue_after_dns_lookup();@@ -1327,6 +1343,23 @@ void Request::handle_dns_lookup_state()}));}+// Pins the request's host, if it was resolved, and its proxy's host, if that's given by name, so that curl resolves+// neither itself.+void Request::set_curl_resolve_list(Optional<ByteString> host_entry)+{+ curl_slist* resolve_list = nullptr;+ if (host_entry.has_value())+ resolve_list = curl_slist_append(resolve_list, host_entry->characters());+ if (auto proxy_entry = curl_resolve_entry_for_proxy(m_proxy); proxy_entry.has_value())+ resolve_list = curl_slist_append(resolve_list, proxy_entry->characters());+ if (!resolve_list)+ return;++ auto result = curl_easy_setopt(m_curl_easy_handle, CURLOPT_RESOLVE, resolve_list);+ VERIFY(result == CURLE_OK);+ m_curl_string_lists.append(resolve_list);+}+StringView Request::connect_host() const{if (m_alternative_service.has_value() && !m_alternative_service->host.is_empty())@@ -1398,15 +1431,7 @@ void Request::handle_connect_state()set_option(CURLOPT_PROXY, m_proxy.has_value() ? m_proxy->to_curl_url().characters() : "");// Pre-populate the multi's hostcache so libcurl skips its threaded resolver entirely.- if (m_dns_result) {- auto formatted_address = build_curl_resolve_list(*m_dns_result, m_url.serialized_host(), m_url.port_or_default());- if (curl_slist* resolve_list = curl_slist_append(nullptr, formatted_address.characters())) {- set_option(CURLOPT_RESOLVE, resolve_list);- m_curl_string_lists.append(resolve_list);- } else {- VERIFY_NOT_REACHED();- }- }+ set_curl_resolve_list(m_dns_result ? build_curl_resolve_list(*m_dns_result, m_url.serialized_host(), m_url.port_or_default()) : Optional<ByteString> {});mark_lifecycle_event(this, &WireStats::curl_added_at);auto result = curl_multi_add_handle(m_curl_multi_handle, m_curl_easy_handle);@@ -1580,16 +1605,7 @@ void Request::handle_fetch_state()set_option(CURLOPT_PROXY, m_proxy.has_value() ? m_proxy->to_curl_url().characters() : "");- if (m_dns_result) {- auto formatted_address = build_curl_resolve_list(*m_dns_result, connect_host(), connect_port());-- if (curl_slist* resolve_list = curl_slist_append(nullptr, formatted_address.characters())) {- set_option(CURLOPT_RESOLVE, resolve_list);- m_curl_string_lists.append(resolve_list);- } else {- VERIFY_NOT_REACHED();- }- }+ set_curl_resolve_list(m_dns_result ? build_curl_resolve_list(*m_dns_result, connect_host(), connect_port()) : Optional<ByteString> {});// libcurl authenticates the alternative as the origin.if (m_alternative_service.has_value() && (connect_host() != m_url.serialized_host() || connect_port() != m_url.port_or_default())) {diff --git a/Services/RequestServer/Request.h b/Services/RequestServer/Request.hindex 53e15d8e439..15523a9d596 100644--- a/Services/RequestServer/Request.h+++ b/Services/RequestServer/Request.h@@ -232,6 +232,7 @@ private:void handle_serve_substitution_state();void handle_dns_lookup_state();void continue_after_dns_lookup();+ void set_curl_resolve_list(Optional<ByteString> host_entry);StringView connect_host() const;void reset_for_retry();void update_alternative_services();@@ -346,6 +347,8 @@ private:NonnullRefPtr<Resolver> m_resolver;RefPtr<DNS::LookupResult const> m_dns_result;+ bool m_proxy_host_resolved { false };+ Optional<HTTP::Proxy> m_resolved_proxy;Optional<HTTP::Proxy> m_proxy;CacheLevel m_connect_cache_level { CacheLevel::ResolveOnly };diff --git a/Services/RequestServer/Resolver.cpp b/Services/RequestServer/Resolver.cppindex 791d422d40a..5c4010625af 100644--- a/Services/RequestServer/Resolver.cpp+++ b/Services/RequestServer/Resolver.cpp@@ -7,6 +7,7 @@#include <AK/NeverDestroyed.h>#include <LibTLS/TLSv12.h>+#include <RequestServer/CURL.h>#include <RequestServer/Resolver.h>namespace RequestServer {@@ -66,6 +67,60 @@ static DNS::Resolver& system_resolver()return *resolver;}+static bool proxy_is_given_by_name(HTTP::Proxy const& proxy)+{+ // A name never contains a colon, so a host with one is an IPv6 address, even with a zone, e.g. fe80::1%eth0.+ return !proxy.host.contains(':') && !IPv4Address::from_string(proxy.host).has_value();+}++static ByteString proxy_key(HTTP::Proxy const& proxy)+{+ return ByteString::formatted("{}:{}", proxy.host, proxy.port);+}++static HashMap<ByteString, ByteString> s_proxy_resolve_entries;++void resolve_proxy_host(Optional<HTTP::Proxy> const& proxy, Function<void(ErrorOr<void>)> on_resolved)+{+ if (!proxy.has_value() || !proxy_is_given_by_name(*proxy)) {+ on_resolved({});+ return;+ }++ // Both outcomes of the lookup call back, so they share the one callback.+ struct Lookup : RefCounted<Lookup> {+ explicit Lookup(Function<void(ErrorOr<void>)> on_resolved)+ : on_resolved(move(on_resolved))+ {+ }+ Function<void(ErrorOr<void>)> on_resolved;+ };+ auto lookup = make_ref_counted<Lookup>(move(on_resolved));++ // Like curl, which this stands in for, look the proxy up with the system resolver, never with a configured DNS+ // server: A proxy is often a local host, which only the system resolver knows.+ auto promise = system_resolver().lookup(proxy->host, DNS::Messages::Class::IN, { DNS::Messages::ResourceType::A, DNS::Messages::ResourceType::AAAA }, { .query_aaaa_without_global_ipv6 = true });+ promise+ ->when_rejected([lookup](auto const& error) {+ lookup->on_resolved(Error::copy(error));+ })+ .when_resolved([lookup, host = proxy->host, port = proxy->port, key = proxy_key(*proxy)](auto const& dns_result) {+ if (dns_result->is_empty() || !dns_result->has_cached_addresses()) {+ lookup->on_resolved(Error::from_string_literal("The proxy's host has no addresses"));+ return;+ }+ s_proxy_resolve_entries.set(key, build_curl_resolve_list(*dns_result, host, port));+ lookup->on_resolved({});+ });+}++Optional<ByteString> curl_resolve_entry_for_proxy(Optional<HTTP::Proxy> const& proxy)+{+ if (!proxy.has_value() || !proxy_is_given_by_name(*proxy))+ return {};+ return s_proxy_resolve_entries.get(proxy_key(*proxy)).copy();+}+static WeakPtr<Resolver> g_default_resolver;static WeakPtr<Resolver> g_private_resolver;diff --git a/Services/RequestServer/Resolver.h b/Services/RequestServer/Resolver.hindex 5524e03994f..8f8faf6401d 100644--- a/Services/RequestServer/Resolver.h+++ b/Services/RequestServer/Resolver.h@@ -52,6 +52,15 @@ private:explicit Resolver(Function<ErrorOr<Optional<DNS::Resolver::SocketResult>>()> create_socket);};+// curl resolves the host of a proxy given by name itself, with the system resolver, unless the handle's CURLOPT_RESOLVE+// list pins it. But RequestServer may not read the files the system resolver needs. So this looks the host up with the+// system resolver the way RequestServer does, for curl_resolve_entry_for_proxy() to pin, and calls back once it has.+// There's nothing to look up for a proxy given as an address, or for no proxy.+void resolve_proxy_host(Optional<HTTP::Proxy> const&, Function<void(ErrorOr<void>)>);++// The CURLOPT_RESOLVE entry that pins the host of a proxy given by name to what resolve_proxy_host() found for it.+Optional<ByteString> curl_resolve_entry_for_proxy(Optional<HTTP::Proxy> const&);+ByteString const& default_certificate_path();void set_default_certificate_path(ByteString);diff --git a/Services/RequestServer/WebSocketImplCurl.cpp b/Services/RequestServer/WebSocketImplCurl.cppindex 4414a08dfb6..837406219a4 100644--- a/Services/RequestServer/WebSocketImplCurl.cpp+++ b/Services/RequestServer/WebSocketImplCurl.cpp@@ -7,6 +7,7 @@#include <LibCore/Notifier.h>#include <RequestServer/CURL.h>#include <RequestServer/ConnectionFromClient.h>+#include <RequestServer/Resolver.h>#include <RequestServer/WebSocketImplCurl.h>namespace RequestServer {@@ -113,8 +114,12 @@ void WebSocketImplCurl::connect(WebSocket::ConnectionInfo const& info)set_option(CURLOPT_HTTPHEADER, curl_headers);m_curl_string_lists.append(curl_headers);- if (auto const& dns_info = info.dns_result(); dns_info.has_value()) {- auto* resolve_list = curl_slist_append(nullptr, build_curl_resolve_list(*dns_info, url.serialized_host(), url.port_or_default()).characters());+ curl_slist* resolve_list = nullptr;+ if (auto const& dns_info = info.dns_result(); dns_info.has_value())+ resolve_list = curl_slist_append(resolve_list, build_curl_resolve_list(*dns_info, url.serialized_host(), url.port_or_default()).characters());+ if (auto proxy_entry = curl_resolve_entry_for_proxy(m_proxy); proxy_entry.has_value())+ resolve_list = curl_slist_append(resolve_list, proxy_entry->characters());+ if (resolve_list) {set_option(CURLOPT_RESOLVE, resolve_list);m_curl_string_lists.append(resolve_list);}diff --git a/Tests/LibDNS/TestDNSResolver.cpp b/Tests/LibDNS/TestDNSResolver.cppindex 70f33d59c59..a2be8e11dab 100644--- a/Tests/LibDNS/TestDNSResolver.cpp+++ b/Tests/LibDNS/TestDNSResolver.cpp@@ -1086,6 +1086,23 @@ TEST_CASE(test_system_resolver_skips_ipv6_addresses_when_ipv6_is_unreachable)EXPECT(!system_resolver.ipv6_answered());}+TEST_CASE(test_system_resolver_resolves_ipv6_addresses_on_request_when_ipv6_is_unreachable)+{+ TestLoop loop;+ SystemResolverWithHeldBackIPv4 system_resolver;+ DNS::Resolver resolver {+ [] -> ErrorOr<Optional<DNS::Resolver::SocketResult>> { return OptionalNone {}; },+ system_resolver.system_resolver(false),+ };++ auto promise = resolver.lookup("proxy.example"sv, DNS::Messages::Class::IN, { DNS::Messages::ResourceType::A, DNS::Messages::ResourceType::AAAA }, { .query_aaaa_without_global_ipv6 = true });+ loop.spin_until([&] { return system_resolver.ipv6_answered(); });+ system_resolver.let_ipv4_answer();+ auto result = TRY_OR_FAIL(promise->await());+ EXPECT(system_resolver.ipv6_answered());+ EXPECT(has_address_of_family(*result, true));+}+TEST_CASE(test_system_resolver_resolves_ipv6_addresses_of_local_names_when_ipv6_is_unreachable){TestLoop loop;diff --git a/Tests/LibHTTP/TestProxy.cpp b/Tests/LibHTTP/TestProxy.cppindex b4d5db836d0..cd91a68a785 100644--- a/Tests/LibHTTP/TestProxy.cpp+++ b/Tests/LibHTTP/TestProxy.cpp@@ -52,6 +52,22 @@ TEST_CASE(parse_proxy)EXPECT(!HTTP::Proxy::parse("http://2001:db8::1:8080"sv).has_value());}+TEST_CASE(parse_proxy_with_ipv6_zone)+{+ auto proxy = HTTP::Proxy::parse("http://[fe80::1%25eth0]:3128"sv);+ EXPECT(proxy.has_value());+ EXPECT_EQ(proxy->host, "fe80::1%25eth0"sv);+ EXPECT_EQ(proxy->to_curl_url(), "http://[fe80::1%25eth0]:3128"sv);+}++TEST_CASE(parse_proxy_with_percent_encoded_host)+{+ auto proxy = HTTP::Proxy::parse("http://%6cocal%2EHost:3128"sv);+ EXPECT(proxy.has_value());+ EXPECT_EQ(proxy->host, "local.host"sv);+ EXPECT_EQ(proxy->to_curl_url(), "http://local.host:3128"sv);+}+TEST_CASE(proxy_hostname_resolution){EXPECT(HTTP::Proxy::parse("http://proxy"sv)->resolves_hostnames());diff --git a/Tests/RequestServer/CMakeLists.txt b/Tests/RequestServer/CMakeLists.txtindex effd2a20fbc..ec69c8639fd 100644--- a/Tests/RequestServer/CMakeLists.txt+++ b/Tests/RequestServer/CMakeLists.txt@@ -8,6 +8,7 @@ set(TEST_SOURCESTestCookieResponses.cppTestDiskCacheWaiters.cppTestExportImport.cpp+ TestProxyHostResolution.cppTestRequestTimingInfo.cppTestSiteBinding.cpp${LADYBIRD_SOURCE_DIR}/Services/RequestServer/AIA.cppdiff --git a/Tests/RequestServer/TestProxyHostResolution.cpp b/Tests/RequestServer/TestProxyHostResolution.cppnew file mode 100644index 00000000000..6803d567ea1--- /dev/null+++ b/Tests/RequestServer/TestProxyHostResolution.cpp@@ -0,0 +1,69 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <LibCore/EventLoop.h>+#include <LibTest/TestCase.h>+#include <RequestServer/Resolver.h>++static HTTP::Proxy proxy_at(StringView host, u16 port)+{+ HTTP::Proxy proxy;+ proxy.type = HTTP::Proxy::Type::HTTP;+ proxy.host = host;+ proxy.port = port;+ return proxy;+}++TEST_CASE(no_proxy_needs_no_lookup_or_pin)+{+ Core::EventLoop loop;+ bool called_back = false;+ RequestServer::resolve_proxy_host({}, [&](ErrorOr<void> result) {+ EXPECT(!result.is_error());+ called_back = true;+ });+ EXPECT(called_back);+ EXPECT(!RequestServer::curl_resolve_entry_for_proxy({}).has_value());+}++TEST_CASE(proxy_given_as_an_address_needs_no_lookup_or_pin)+{+ Core::EventLoop loop;+ for (auto host : { "192.0.2.1"sv, "::1"sv, "fe80::1%eth0"sv, "fe80::1%25eth0"sv }) {+ auto proxy = proxy_at(host, 3128);+ bool called_back = false;+ RequestServer::resolve_proxy_host(proxy, [&](ErrorOr<void> result) {+ EXPECT(!result.is_error());+ called_back = true;+ });+ EXPECT(called_back);+ EXPECT(!RequestServer::curl_resolve_entry_for_proxy(proxy).has_value());+ }+}++TEST_CASE(proxy_given_by_name_is_pinned_to_the_addresses_found)+{+ Core::EventLoop loop;+ auto proxy = proxy_at("localhost"sv, 3128);+ EXPECT(!RequestServer::curl_resolve_entry_for_proxy(proxy).has_value());++ bool called_back = false;+ bool failed = false;+ RequestServer::resolve_proxy_host(proxy, [&](ErrorOr<void> result) {+ failed = result.is_error();+ called_back = true;+ });+ loop.spin_until([&] { return called_back; });+ EXPECT(!failed);++ auto entry = RequestServer::curl_resolve_entry_for_proxy(proxy);+ EXPECT(entry.has_value());+ EXPECT(entry->starts_with("localhost:3128:"sv));+ EXPECT(entry->contains("127.0.0.1"sv));++ // A pin is for the host and port the proxy was looked up with, and no other.+ EXPECT(!RequestServer::curl_resolve_entry_for_proxy(proxy_at("localhost"sv, 8080)).has_value());+}