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