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_COMMON_PLATFORM_API_QUICHE_HOSTNAME_UTILS_H_ 6 #define QUICHE_COMMON_PLATFORM_API_QUICHE_HOSTNAME_UTILS_H_ 7 8 #include <string> 9 10 #include "absl/strings/string_view.h" 11 #include "quiche/common/platform/api/quiche_export.h" 12 13 namespace quiche { 14 15 class QUICHE_EXPORT QuicheHostnameUtils { 16 public: 17 QuicheHostnameUtils() = delete; 18 19 // Returns true if the sni is valid, false otherwise. 20 // (1) disallow IP addresses; 21 // (2) check that the hostname contains valid characters only; and 22 // (3) contains at least one dot. 23 static bool IsValidSNI(absl::string_view sni); 24 25 // Canonicalizes the specified hostname. This involves a wide variety of 26 // transformations, including lowercasing, removing trailing dots and IDNA 27 // conversion. 28 static std::string NormalizeHostname(absl::string_view hostname); 29 }; 30 31 } // namespace quiche 32 33 #endif // QUICHE_COMMON_PLATFORM_API_QUICHE_HOSTNAME_UTILS_H_ 34