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