#include "quiche/quic/masque/masque_client_session.h"
#include <cstdint>
#include <cstring>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "openssl/curve25519.h"
#include "quiche/quic/core/crypto/quic_crypto_client_config.h"
#include "quiche/quic/core/frames/quic_connection_close_frame.h"
#include "quiche/quic/core/http/http_frames.h"
#include "quiche/quic/core/http/quic_spdy_client_session.h"
#include "quiche/quic/core/http/quic_spdy_client_stream.h"
#include "quiche/quic/core/quic_config.h"
#include "quiche/quic/core/quic_connection.h"
#include "quiche/quic/core/quic_data_reader.h"
#include "quiche/quic/core/quic_data_writer.h"
#include "quiche/quic/core/quic_error_codes.h"
#include "quiche/quic/core/quic_server_id.h"
#include "quiche/quic/core/quic_time.h"
#include "quiche/quic/core/quic_types.h"
#include "quiche/quic/core/quic_utils.h"
#include "quiche/quic/core/quic_versions.h"
#include "quiche/quic/masque/masque_utils.h"
#include "quiche/quic/platform/api/quic_bug_tracker.h"
#include "quiche/quic/platform/api/quic_logging.h"
#include "quiche/quic/platform/api/quic_socket_address.h"
#include "quiche/quic/tools/quic_url.h"
#include "quiche/common/capsule.h"
#include "quiche/common/http/http_header_block.h"
#include "quiche/common/platform/api/quiche_googleurl.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/platform/api/quiche_url_utils.h"
#include "quiche/common/quiche_ip_address.h"
#include "quiche/common/quiche_random.h"
#include "quiche/common/quiche_text_utils.h"
namespace quic {
namespace {
AddressAssignCapsule;
AddressRequestCapsule;
RouteAdvertisementCapsule;
constexpr uint64_t kConnectIpPayloadContextId = …;
constexpr uint64_t kConnectEthernetPayloadContextId = …;
}
MasqueClientSession::MasqueClientSession(
MasqueMode masque_mode, const std::string& uri_template,
const QuicConfig& config, const ParsedQuicVersionVector& supported_versions,
QuicConnection* connection, const QuicServerId& server_id,
QuicCryptoClientConfig* crypto_config, Owner* owner)
: … { … }
MasqueClientSession::MasqueClientSession(
const QuicConfig& config, const ParsedQuicVersionVector& supported_versions,
QuicConnection* connection, const QuicServerId& server_id,
QuicCryptoClientConfig* crypto_config, Owner* owner)
: … { … }
void MasqueClientSession::OnMessageAcked(QuicMessageId message_id,
QuicTime ) { … }
void MasqueClientSession::OnMessageLost(QuicMessageId message_id) { … }
const MasqueClientSession::ConnectUdpClientState*
MasqueClientSession::GetOrCreateConnectUdpClientState(
const QuicSocketAddress& target_server_address,
EncapsulatedClientSession* encapsulated_client_session) { … }
const MasqueClientSession::ConnectIpClientState*
MasqueClientSession::GetOrCreateConnectIpClientState(
MasqueClientSession::EncapsulatedIpSession* encapsulated_ip_session) { … }
const MasqueClientSession::ConnectEthernetClientState*
MasqueClientSession::GetOrCreateConnectEthernetClientState(
MasqueClientSession::EncapsulatedEthernetSession*
encapsulated_ethernet_session) { … }
void MasqueClientSession::SendIpPacket(
absl::string_view packet,
MasqueClientSession::EncapsulatedIpSession* encapsulated_ip_session) { … }
void MasqueClientSession::SendEthernetFrame(
absl::string_view frame, MasqueClientSession::EncapsulatedEthernetSession*
encapsulated_ethernet_session) { … }
void MasqueClientSession::SendPacket(
absl::string_view packet, const QuicSocketAddress& target_server_address,
EncapsulatedClientSession* encapsulated_client_session) { … }
void MasqueClientSession::CloseConnectUdpStream(
EncapsulatedClientSession* encapsulated_client_session) { … }
void MasqueClientSession::CloseConnectIpStream(
EncapsulatedIpSession* encapsulated_ip_session) { … }
void MasqueClientSession::CloseConnectEthernetStream(
EncapsulatedEthernetSession* encapsulated_ethernet_session) { … }
void MasqueClientSession::OnConnectionClosed(
const QuicConnectionCloseFrame& frame, ConnectionCloseSource source) { … }
void MasqueClientSession::OnStreamClosed(QuicStreamId stream_id) { … }
bool MasqueClientSession::OnSettingsFrame(const SettingsFrame& frame) { … }
MasqueClientSession::ConnectUdpClientState::ConnectUdpClientState(
QuicSpdyClientStream* stream,
EncapsulatedClientSession* encapsulated_client_session,
MasqueClientSession* masque_session,
const QuicSocketAddress& target_server_address)
: … { … }
MasqueClientSession::ConnectUdpClientState::~ConnectUdpClientState() { … }
MasqueClientSession::ConnectUdpClientState::ConnectUdpClientState(
MasqueClientSession::ConnectUdpClientState&& other) { … }
MasqueClientSession::ConnectUdpClientState&
MasqueClientSession::ConnectUdpClientState::operator=(
MasqueClientSession::ConnectUdpClientState&& other) { … }
void MasqueClientSession::ConnectUdpClientState::OnHttp3Datagram(
QuicStreamId stream_id, absl::string_view payload) { … }
MasqueClientSession::ConnectIpClientState::ConnectIpClientState(
QuicSpdyClientStream* stream,
EncapsulatedIpSession* encapsulated_ip_session,
MasqueClientSession* masque_session)
: … { … }
MasqueClientSession::ConnectIpClientState::~ConnectIpClientState() { … }
MasqueClientSession::ConnectIpClientState::ConnectIpClientState(
MasqueClientSession::ConnectIpClientState&& other) { … }
MasqueClientSession::ConnectIpClientState&
MasqueClientSession::ConnectIpClientState::operator=(
MasqueClientSession::ConnectIpClientState&& other) { … }
void MasqueClientSession::ConnectIpClientState::OnHttp3Datagram(
QuicStreamId stream_id, absl::string_view payload) { … }
bool MasqueClientSession::ConnectIpClientState::OnAddressAssignCapsule(
const AddressAssignCapsule& capsule) { … }
bool MasqueClientSession::ConnectIpClientState::OnAddressRequestCapsule(
const AddressRequestCapsule& capsule) { … }
bool MasqueClientSession::ConnectIpClientState::OnRouteAdvertisementCapsule(
const RouteAdvertisementCapsule& capsule) { … }
void MasqueClientSession::ConnectIpClientState::OnHeadersWritten() { … }
MasqueClientSession::ConnectEthernetClientState::ConnectEthernetClientState(
QuicSpdyClientStream* stream,
EncapsulatedEthernetSession* encapsulated_ethernet_session,
MasqueClientSession* masque_session)
: … { … }
MasqueClientSession::ConnectEthernetClientState::~ConnectEthernetClientState() { … }
MasqueClientSession::ConnectEthernetClientState::ConnectEthernetClientState(
MasqueClientSession::ConnectEthernetClientState&& other) { … }
MasqueClientSession::ConnectEthernetClientState&
MasqueClientSession::ConnectEthernetClientState::operator=(
MasqueClientSession::ConnectEthernetClientState&& other) { … }
void MasqueClientSession::ConnectEthernetClientState::OnHttp3Datagram(
QuicStreamId stream_id, absl::string_view payload) { … }
quiche::QuicheIpAddress MasqueClientSession::GetFakeAddress(
absl::string_view hostname) { … }
void MasqueClientSession::RemoveFakeAddress(
const quiche::QuicheIpAddress& fake_address) { … }
void MasqueClientSession::EnableConcealedAuth(absl::string_view key_id,
absl::string_view private_key,
absl::string_view public_key) { … }
QuicSpdyClientStream* MasqueClientSession::SendGetRequest(
absl::string_view path) { … }
void MasqueClientSession::OnClose(QuicSpdyStream* stream) { … }
std::optional<std::string> MasqueClientSession::ComputeConcealedAuthHeader(
const QuicUrl& url) { … }
void MasqueClientSession::AddAdditionalHeaders(quiche::HttpHeaderBlock& headers,
const QuicUrl& url) { … }
}