1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_QUIC_QUIC_SESSION_KEY_H_
6 #define NET_QUIC_QUIC_SESSION_KEY_H_
8 #include "net/base/host_port_pair.h"
9 #include "net/base/network_anonymization_key.h"
10 #include "net/base/privacy_mode.h"
11 #include "net/dns/public/secure_dns_policy.h"
12 #include "net/socket/socket_tag.h"
13 #include "net/third_party/quiche/src/quiche/quic/core/quic_server_id.h"
17 // The key used to identify sessions. Includes the quic::QuicServerId and socket
19 class NET_EXPORT_PRIVATE QuicSessionKey {
22 QuicSessionKey(const HostPortPair& host_port_pair,
23 PrivacyMode privacy_mode,
24 const SocketTag& socket_tag,
25 const NetworkAnonymizationKey& network_anonymization_key,
26 SecureDnsPolicy secure_dns_policy,
27 bool require_dns_https_alpn);
28 QuicSessionKey(const std::string& host,
30 PrivacyMode privacy_mode,
31 const SocketTag& socket_tag,
32 const NetworkAnonymizationKey& network_anonymization_key,
33 SecureDnsPolicy secure_dns_policy,
34 bool require_dns_https_alpn);
35 QuicSessionKey(const quic::QuicServerId& server_id,
36 const SocketTag& socket_tag,
37 const NetworkAnonymizationKey& network_anonymization_key,
38 SecureDnsPolicy secure_dns_policy,
39 bool require_dns_https_alpn);
40 QuicSessionKey(const QuicSessionKey& other);
41 ~QuicSessionKey() = default;
43 // Needed to be an element of std::set.
44 bool operator<(const QuicSessionKey& other) const;
45 bool operator==(const QuicSessionKey& other) const;
47 // Checks if requests using QuicSessionKey can potentially be used to service
48 // requests using another. Returns true if all fields except QuicServerId's
49 // host and port match. The caller *MUST* also make sure that the session
50 // associated with one key has been verified for use with the host/port of the
53 // Note that this method is symmetric, so it doesn't matter which key's method
54 // is called on the other.
55 bool CanUseForAliasing(const QuicSessionKey& other) const;
57 const std::string& host() const { return server_id_.host(); }
59 PrivacyMode privacy_mode() const {
60 return server_id_.privacy_mode_enabled() ? PRIVACY_MODE_ENABLED
61 : PRIVACY_MODE_DISABLED;
64 const quic::QuicServerId& server_id() const { return server_id_; }
66 SocketTag socket_tag() const { return socket_tag_; }
68 const NetworkAnonymizationKey& network_anonymization_key() const {
69 return network_anonymization_key_;
72 SecureDnsPolicy secure_dns_policy() const { return secure_dns_policy_; }
74 bool require_dns_https_alpn() const { return require_dns_https_alpn_; }
77 quic::QuicServerId server_id_;
78 SocketTag socket_tag_;
79 // Used to separate requests made in different contexts.
80 NetworkAnonymizationKey network_anonymization_key_;
81 SecureDnsPolicy secure_dns_policy_;
82 bool require_dns_https_alpn_ = false;
87 #endif // NET_QUIC_QUIC_SESSION_KEY_H_