blob: 39fafc5775bb29b74d9b1a20dce466c08f7f2a75 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2020 The Chromium Authors
Cammie Smith Barnes958c7f32020-12-17 16:43:112// 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
Eric Orthac661912022-01-10 21:44:178#include <set>
Cammie Smith Barnes958c7f32020-12-17 16:43:119#include <string>
Cammie Smith Barnes958c7f32020-12-17 16:43:1110
Eric Orth8677ec2a2022-02-22 21:31:0611#include "base/strings/string_piece.h"
Cammie Smith Barnes958c7f32020-12-17 16:43:1112#include "net/base/net_export.h"
13
Tsuyoshi Horo4f516be2022-06-14 11:53:1314namespace net::dns_alias_utility {
Cammie Smith Barnes958c7f32020-12-17 16:43:1115
Eric Orthac661912022-01-10 21:44:1716// 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.
23NET_EXPORT_PRIVATE std::set<std::string> FixUpDnsAliases(
24 const std::set<std::string>& aliases);
Cammie Smith Barnes958c7f32020-12-17 16:43:1125
Tsuyoshi Horo4f516be2022-06-14 11:53:1326} // namespace net::dns_alias_utility
Cammie Smith Barnes958c7f32020-12-17 16:43:1127
28#endif // NET_DNS_DNS_ALIAS_UTILITY_H_