dns_alias_utility.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_DNS_DNS_ALIAS_UTILITY_H_
  5. #define NET_DNS_DNS_ALIAS_UTILITY_H_
  6. #include <set>
  7. #include <string>
  8. #include "base/strings/string_piece.h"
  9. #include "net/base/net_export.h"
  10. namespace net::dns_alias_utility {
  11. // Validates that `alias` represents a valid DNS alias name, e.g. CNAME, and
  12. // then URL-canonicalizes the name. Returns empty string if not valid or unable
  13. // to canonicalize.
  14. NET_EXPORT_PRIVATE std::string ValidateAndCanonicalizeAlias(
  15. base::StringPiece alias);
  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. } // namespace net::dns_alias_utility
  26. #endif // NET_DNS_DNS_ALIAS_UTILITY_H_