blob: 6a04044b7147149241502ad76e778cece11e300b [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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
vasilvv872e7a32019-03-12 16:42:44 -07008#include <string>
9
QUICHE teama6ef0a62019-03-07 20:34:33 -050010#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050011#include "net/quic/platform/impl/quic_hostname_utils_impl.h"
dmcardle60acc062019-12-13 09:43:04 -080012#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050013
14namespace quic {
15
16class 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.
dmcardle60acc062019-12-13 09:43:04 -080024 static bool IsValidSNI(quiche::QuicheStringPiece sni);
QUICHE teama6ef0a62019-03-07 20:34:33 -050025
26 // Canonicalizes the specified hostname. This involves a wide variety of
27 // transformations, including lowercasing, removing trailing dots and IDNA
28 // conversion.
dmcardle60acc062019-12-13 09:43:04 -080029 static std::string NormalizeHostname(quiche::QuicheStringPiece hostname);
QUICHE teama6ef0a62019-03-07 20:34:33 -050030};
31
32} // namespace quic
33
34#endif // QUICHE_QUIC_PLATFORM_API_QUIC_HOSTNAME_UTILS_H_