blob: 6de1ad6c68a2157b344002d64659e47ce1e23532 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2018 The Chromium Authors
Paul Jensen8e3c5d32018-02-19 17:06:332// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Ryan Hamiltona3ee93a72018-08-01 22:03:085#include "net/quic/quic_session_key.h"
Paul Jensen8e3c5d32018-02-19 17:06:336
Matt Menke26e41542019-06-05 01:09:517#include "base/feature_list.h"
8#include "net/base/features.h"
Ben Schwartz3ff4dc1e62021-04-27 21:15:239#include "net/dns/public/secure_dns_policy.h"
Matt Menke26e41542019-06-05 01:09:5110
Paul Jensen8e3c5d32018-02-19 17:06:3311namespace net {
12
dalyka92863972019-10-14 20:25:5813QuicSessionKey::QuicSessionKey() = default;
14
Brianna Goldstein793995c2022-09-27 04:27:3715QuicSessionKey::QuicSessionKey(
16 const HostPortPair& host_port_pair,
17 PrivacyMode privacy_mode,
18 const SocketTag& socket_tag,
19 const NetworkAnonymizationKey& network_anonymization_key,
20 SecureDnsPolicy secure_dns_policy,
21 bool require_dns_https_alpn)
Ryan Hamilton4f0b26e2018-06-27 23:52:3222 : QuicSessionKey(host_port_pair.host(),
23 host_port_pair.port(),
24 privacy_mode,
Matt Menke26e41542019-06-05 01:09:5125 socket_tag,
Brianna Goldstein793995c2022-09-27 04:27:3726 network_anonymization_key,
Tsuyoshi Horo7acebce2022-05-12 06:13:2327 secure_dns_policy,
28 require_dns_https_alpn) {}
Paul Jensen8e3c5d32018-02-19 17:06:3329
Brianna Goldstein793995c2022-09-27 04:27:3730QuicSessionKey::QuicSessionKey(
31 const std::string& host,
32 uint16_t port,
33 PrivacyMode privacy_mode,
34 const SocketTag& socket_tag,
35 const NetworkAnonymizationKey& network_anonymization_key,
36 SecureDnsPolicy secure_dns_policy,
37 bool require_dns_https_alpn)
Ryan Hamilton4f0b26e2018-06-27 23:52:3238 : QuicSessionKey(
Rayan Kanso90e6b602020-07-09 18:15:5439 // TODO(crbug.com/1103350): Handle non-boolean privacy modes.
Dylan Cutler86f47b02022-01-21 01:12:2240 quic::QuicServerId(host, port, privacy_mode != PRIVACY_MODE_DISABLED),
Matt Menke26e41542019-06-05 01:09:5141 socket_tag,
Brianna Goldstein793995c2022-09-27 04:27:3742 network_anonymization_key,
Tsuyoshi Horo7acebce2022-05-12 06:13:2343 secure_dns_policy,
44 require_dns_https_alpn) {}
Paul Jensen8e3c5d32018-02-19 17:06:3345
Brianna Goldstein793995c2022-09-27 04:27:3746QuicSessionKey::QuicSessionKey(
47 const quic::QuicServerId& server_id,
48 const SocketTag& socket_tag,
49 const NetworkAnonymizationKey& network_anonymization_key,
50 SecureDnsPolicy secure_dns_policy,
51 bool require_dns_https_alpn)
Matt Menke26e41542019-06-05 01:09:5152 : server_id_(server_id),
53 socket_tag_(socket_tag),
Brianna Goldstein793995c2022-09-27 04:27:3754 network_anonymization_key_(
Dustin J. Mitchell5624da42023-04-20 18:26:1755 NetworkAnonymizationKey::IsPartitioningEnabled()
Brianna Goldstein793995c2022-09-27 04:27:3756 ? network_anonymization_key
57 : NetworkAnonymizationKey()),
Tsuyoshi Horo7acebce2022-05-12 06:13:2358 secure_dns_policy_(secure_dns_policy),
59 require_dns_https_alpn_(require_dns_https_alpn) {}
dalyka92863972019-10-14 20:25:5860
61QuicSessionKey::QuicSessionKey(const QuicSessionKey& other) = default;
Paul Jensen8e3c5d32018-02-19 17:06:3362
63bool QuicSessionKey::operator<(const QuicSessionKey& other) const {
Brianna Goldstein793995c2022-09-27 04:27:3764 return std::tie(server_id_, socket_tag_, network_anonymization_key_,
Tsuyoshi Horo7acebce2022-05-12 06:13:2365 secure_dns_policy_, require_dns_https_alpn_) <
Matt Menke26e41542019-06-05 01:09:5166 std::tie(other.server_id_, other.socket_tag_,
Brianna Goldstein793995c2022-09-27 04:27:3767 other.network_anonymization_key_, other.secure_dns_policy_,
Tsuyoshi Horo7acebce2022-05-12 06:13:2368 other.require_dns_https_alpn_);
Paul Jensen8e3c5d32018-02-19 17:06:3369}
70bool QuicSessionKey::operator==(const QuicSessionKey& other) const {
Matt Menke26e41542019-06-05 01:09:5171 return server_id_ == other.server_id_ && socket_tag_ == other.socket_tag_ &&
Brianna Goldstein793995c2022-09-27 04:27:3772 network_anonymization_key_ == other.network_anonymization_key_ &&
Tsuyoshi Horo7acebce2022-05-12 06:13:2373 secure_dns_policy_ == other.secure_dns_policy_ &&
74 require_dns_https_alpn_ == other.require_dns_https_alpn_;
Paul Jensen8e3c5d32018-02-19 17:06:3375}
76
Matt Menke4697318e2020-07-16 22:12:0077bool QuicSessionKey::CanUseForAliasing(const QuicSessionKey& other) const {
78 return server_id_.privacy_mode_enabled() ==
79 other.server_id_.privacy_mode_enabled() &&
80 socket_tag_ == other.socket_tag_ &&
Brianna Goldstein793995c2022-09-27 04:27:3781 network_anonymization_key_ == other.network_anonymization_key_ &&
Tsuyoshi Horo7acebce2022-05-12 06:13:2382 secure_dns_policy_ == other.secure_dns_policy_ &&
83 require_dns_https_alpn_ == other.require_dns_https_alpn_;
Matt Menke4697318e2020-07-16 22:12:0084}
85
Ryan Hamilton4f0b26e2018-06-27 23:52:3286} // namespace net