Skip to content
Snippets Groups Projects
Commit b8267b36 authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Chromium LUCI CQ
Browse files

Make HostResolver::AllProtocolEndpointsHaveEch() generic

So that we can call the function for both HostResolverEndpointResult
and ServiceEndpoint. This is a preparation for supporting ECH in
HttpStreamPool.

No behavior changes.

Bug: 346835898
Change-Id: I31be2c8a2057c8a78690454c0d9fd5c152da3db1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5775902


Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Reviewed-by: default avatarTsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1339996}
parent 89ed9842
No related branches found
No related tags found
No related merge requests found
......@@ -515,23 +515,6 @@ AddressList HostResolver::EndpointResultToAddressList(
return list;
}
// static
bool HostResolver::AllProtocolEndpointsHaveEch(
base::span<const HostResolverEndpointResult> endpoints) {
bool has_svcb = false;
for (const auto& endpoint : endpoints) {
if (!endpoint.metadata.supported_protocol_alpns.empty()) {
has_svcb = true;
if (endpoint.metadata.ech_config_list.empty()) {
return false; // There is a non-ECH SVCB/HTTPS route.
}
}
}
// Either there were no SVCB/HTTPS records (should be SVCB-optional), or there
// were and all supported ECH (should be SVCB-reliant).
return has_svcb;
}
// static
bool HostResolver::MayUseNAT64ForIPv4Literal(HostResolverFlags flags,
HostResolverSource source,
......
......@@ -13,12 +13,14 @@
#include <set>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>
#include "base/containers/span.h"
#include "base/values.h"
#include "net/base/address_family.h"
#include "net/base/completion_once_callback.h"
#include "net/base/connection_endpoint_metadata.h"
#include "net/base/host_port_pair.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/network_handle.h"
......@@ -46,6 +48,11 @@ class HostResolverManager;
class NetLog;
class URLRequestContext;
template <typename T>
concept HasConnectionEndpointMetadata = requires(T t) {
{ t.metadata } -> std::same_as<ConnectionEndpointMetadata&>;
};
// This class represents the task of resolving hostnames (or IP address
// literal) to an AddressList object (or other DNS-style results).
//
......@@ -589,9 +596,24 @@ class NET_EXPORT HostResolver {
// Returns whether there is at least one protocol endpoint in `endpoints`, and
// all such endpoints have ECH parameters. This can be used to implement the
// guidance in section 10.1 of draft-ietf-dnsop-svcb-https-11.
static bool AllProtocolEndpointsHaveEch(
base::span<const HostResolverEndpointResult> endpoints);
// guidance in section 3 of RFC9460.
template <typename T>
static bool AllProtocolEndpointsHaveEch(base::span<const T> endpoints)
requires HasConnectionEndpointMetadata<T>
{
bool has_svcb = false;
for (const auto& endpoint : endpoints) {
if (!endpoint.metadata.supported_protocol_alpns.empty()) {
has_svcb = true;
if (endpoint.metadata.ech_config_list.empty()) {
return false; // There is a non-ECH SVCB/HTTPS route.
}
}
}
// Either there were no SVCB/HTTPS records (should be SVCB-optional), or
// there were and all supported ECH (should be SVCB-reliant).
return has_svcb;
}
// Returns true if NAT64 can be used in place of an IPv4 address during host
// resolution.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment