OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_ | 5 #ifndef NET_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_ |
6 #define NET_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_ | 6 #define NET_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "net/quic/platform/api/quic_export.h" | 9 #include "net/quic/platform/api/quic_export.h" |
| 10 #include "net/quic/platform/api/quic_string_piece.h" |
10 #include "net/quic/platform/impl/quic_hostname_utils_impl.h" | 11 #include "net/quic/platform/impl/quic_hostname_utils_impl.h" |
11 | 12 |
12 namespace net { | 13 namespace net { |
13 | 14 |
14 class QuicServerId; | 15 class QuicServerId; |
15 | 16 |
16 class QUIC_EXPORT_PRIVATE QuicHostnameUtils { | 17 class QUIC_EXPORT_PRIVATE QuicHostnameUtils { |
17 public: | 18 public: |
18 // Returns true if the sni is valid, false otherwise. | 19 // Returns true if the sni is valid, false otherwise. |
19 // (1) disallow IP addresses; | 20 // (1) disallow IP addresses; |
20 // (2) check that the hostname contains valid characters only; and | 21 // (2) check that the hostname contains valid characters only; and |
21 // (3) contains at least one dot. | 22 // (3) contains at least one dot. |
22 static bool IsValidSNI(base::StringPiece sni); | 23 static bool IsValidSNI(QuicStringPiece sni); |
23 | 24 |
24 // Convert hostname to lowercase and remove the trailing '.'. | 25 // Convert hostname to lowercase and remove the trailing '.'. |
25 // WARNING: mutates |hostname| in place and returns |hostname|. | 26 // WARNING: mutates |hostname| in place and returns |hostname|. |
26 static char* NormalizeHostname(char* hostname); | 27 static char* NormalizeHostname(char* hostname); |
27 | 28 |
28 // Creates a QuicServerId from a string formatted in same manner as | 29 // Creates a QuicServerId from a string formatted in same manner as |
29 // QuicServerId::ToString(). | 30 // QuicServerId::ToString(). |
30 static void StringToQuicServerId(const std::string& str, QuicServerId* out); | 31 static void StringToQuicServerId(const std::string& str, QuicServerId* out); |
31 | 32 |
32 private: | 33 private: |
33 DISALLOW_COPY_AND_ASSIGN(QuicHostnameUtils); | 34 DISALLOW_COPY_AND_ASSIGN(QuicHostnameUtils); |
34 }; | 35 }; |
35 | 36 |
36 } // namespace net | 37 } // namespace net |
37 | 38 |
38 #endif // NET_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_ | 39 #endif // NET_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_ |
OLD | NEW |