QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_ |
| 6 | #define QUICHE_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_ |
| 7 | |
vasilvv | 872e7a3 | 2019-03-12 16:42:44 -0700 | [diff] [blame] | 8 | #include <string> |
| 9 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 10 | #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 11 | #include "net/quic/platform/impl/quic_hostname_utils_impl.h" |
dmcardle | 60acc06 | 2019-12-13 09:43:04 -0800 | [diff] [blame] | 12 | #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 13 | |
| 14 | namespace quic { |
| 15 | |
| 16 | class QUIC_EXPORT_PRIVATE QuicHostnameUtils { |
| 17 | public: |
| 18 | QuicHostnameUtils() = delete; |
| 19 | |
| 20 | // Returns true if the sni is valid, false otherwise. |
| 21 | // (1) disallow IP addresses; |
| 22 | // (2) check that the hostname contains valid characters only; and |
| 23 | // (3) contains at least one dot. |
dmcardle | 60acc06 | 2019-12-13 09:43:04 -0800 | [diff] [blame] | 24 | static bool IsValidSNI(quiche::QuicheStringPiece sni); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 25 | |
| 26 | // Canonicalizes the specified hostname. This involves a wide variety of |
| 27 | // transformations, including lowercasing, removing trailing dots and IDNA |
| 28 | // conversion. |
dmcardle | 60acc06 | 2019-12-13 09:43:04 -0800 | [diff] [blame] | 29 | static std::string NormalizeHostname(quiche::QuicheStringPiece hostname); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | } // namespace quic |
| 33 | |
| 34 | #endif // QUICHE_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_ |