xref: /aosp_15_r20/external/cronet/net/dns/dns_alias_utility.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_DNS_DNS_ALIAS_UTILITY_H_
6 #define NET_DNS_DNS_ALIAS_UTILITY_H_
7 
8 #include <set>
9 #include <string>
10 
11 #include "base/strings/string_piece.h"
12 #include "net/base/net_export.h"
13 
14 namespace net::dns_alias_utility {
15 
16 // Returns a fixed up set of canonicalized aliases (i.e. aliases that are
17 // written as hostnames for canonical URLs). The set is stripped of "localhost",
18 // IP addresses, duplicates, the empty string, strings longer than
19 // `dns_protocol::kMaxCharNameLength` characters (with one extra character
20 // allowed for fully-qualified hostnames, i.e. hostnames ending with '.'), and
21 // any strings that fail to URL-canonicalize as hosts. The remaining aliases are
22 // replaced with their canonicalized forms.
23 NET_EXPORT_PRIVATE std::set<std::string> FixUpDnsAliases(
24     const std::set<std::string>& aliases);
25 
26 }  // namespace net::dns_alias_utility
27 
28 #endif  // NET_DNS_DNS_ALIAS_UTILITY_H_
29