Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1088)

Side by Side Diff: net/dns/dns_util.h

Issue 2739203003: Measure how often DNS hostnames aren't in preferred name form. (Closed)
Patch Set: Change the behavior to reporting via UMA; add documentation. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/dns/dns_util.cc » ('j') | net/dns/dns_util.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_DNS_DNS_UTIL_H_ 5 #ifndef NET_DNS_DNS_UTIL_H_
6 #define NET_DNS_DNS_UTIL_H_ 6 #define NET_DNS_DNS_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
13 #include "net/base/network_change_notifier.h" 13 #include "net/base/network_change_notifier.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 class AddressList; 17 class AddressList;
18 18
19 // DNSDomainFromDot - convert a domain string to DNS format. From DJB's 19 // DNSDomainFromDot - convert a domain string to DNS format. From DJB's
20 // public domain DNS library. 20 // public domain DNS library.
21 // 21 //
22 // dotted: a string in dotted form: "www.google.com" 22 // dotted: a string in dotted form: "www.google.com"
23 // out: a result in DNS form: "\x03www\x06google\x03com\x00" 23 // out: a result in DNS form: "\x03www\x06google\x03com\x00"
24 NET_EXPORT_PRIVATE bool DNSDomainFromDot(const base::StringPiece& dotted, 24 NET_EXPORT_PRIVATE bool DNSDomainFromDot(const base::StringPiece& dotted,
25 std::string* out); 25 std::string* out);
26 26
27 // Checks that a hostname is valid. Simple wrapper around DNSDomainFromDot. 27 // Checks that a hostname is valid. Simple wrapper around DNSDomainFromDot.
28 NET_EXPORT_PRIVATE bool IsValidDNSDomain(const base::StringPiece& dotted); 28 NET_EXPORT_PRIVATE bool IsValidDNSDomain(const base::StringPiece& dotted);
29 29
30 // Returns true if the character is valid in a DNS hostname label, whether in
31 // the first position or later in the label.
32 //
33 // This function asserts a looser form of the restrictions in RFC 1123 (section
Ryan Sleevi 2017/03/22 00:16:07 https://tools.ietf.org/html/rfc7719#section-2 is m
palmer 2017/03/22 01:03:33 Done.
34 // 2.1): hostnames can include characters a-z, A-Z, 0-9, -, and _, and any of
35 // those characters (except -) are legal in the first position. The looser rules
36 // are necessary to support service records (initial _), and non-compliant but
37 // attested hostnames that include _. These looser rules also allow Punycode and
38 // hence IDN.
39 //
40 // TODO(palmer): In the future, when we can remove support for invalid names,
41 // this can be a private implementation detail of |DNSDomainFromDot|, and need
42 // not be NET_EXPORT_PRIVATE.
43 NET_EXPORT_PRIVATE bool IsValidLabelCharacter(char c, bool is_first_char);
Ryan Sleevi 2017/03/22 00:16:07 pedantry: IsValidHostLabelCharacter? Since other l
palmer 2017/03/22 01:03:34 Done.
44
30 // DNSDomainToString converts a domain in DNS format to a dotted string. 45 // DNSDomainToString converts a domain in DNS format to a dotted string.
31 // Excludes the dot at the end. 46 // Excludes the dot at the end.
32 NET_EXPORT_PRIVATE std::string DNSDomainToString( 47 NET_EXPORT_PRIVATE std::string DNSDomainToString(
33 const base::StringPiece& domain); 48 const base::StringPiece& domain);
34 49
35 #if !defined(OS_NACL) 50 #if !defined(OS_NACL)
36 NET_EXPORT_PRIVATE 51 NET_EXPORT_PRIVATE
37 base::TimeDelta GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault( 52 base::TimeDelta GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault(
38 const char* field_trial_name, 53 const char* field_trial_name,
39 base::TimeDelta default_delta, 54 base::TimeDelta default_delta,
(...skipping 15 matching lines...) Expand all
55 }; 70 };
56 71
57 // Compares two AddressLists to see how similar or different their addresses 72 // Compares two AddressLists to see how similar or different their addresses
58 // are. (See |AddressListDeltaType| for details of exactly what's checked.) 73 // are. (See |AddressListDeltaType| for details of exactly what's checked.)
59 AddressListDeltaType FindAddressListDeltaType(const AddressList& a, 74 AddressListDeltaType FindAddressListDeltaType(const AddressList& a,
60 const AddressList& b); 75 const AddressList& b);
61 76
62 } // namespace net 77 } // namespace net
63 78
64 #endif // NET_DNS_DNS_UTIL_H_ 79 #endif // NET_DNS_DNS_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | net/dns/dns_util.cc » ('j') | net/dns/dns_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698