#include "quiche/quic/masque/masque_server_session.h"
#include <fcntl.h>
#include <netdb.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/udp.h>
#include <cstdint>
#include <limits>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "absl/algorithm/container.h"
#include "absl/cleanup/cleanup.h"
#include "absl/strings/escaping.h"
#include "absl/strings/numbers.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_compressed_certs_cache.h"
#include "quiche/quic/core/crypto/quic_crypto_server_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_stream.h"
#include "quiche/quic/core/io/quic_event_loop.h"
#include "quiche/quic/core/quic_config.h"
#include "quiche/quic/core/quic_connection.h"
#include "quiche/quic/core/quic_constants.h"
#include "quiche/quic/core/quic_crypto_server_stream_base.h"
#include "quiche/quic/core/quic_data_reader.h"
#include "quiche/quic/core/quic_session.h"
#include "quiche/quic/core/quic_time.h"
#include "quiche/quic/core/quic_types.h"
#include "quiche/quic/core/quic_udp_socket.h"
#include "quiche/quic/core/quic_versions.h"
#include "quiche/quic/masque/masque_server_backend.h"
#include "quiche/quic/masque/masque_utils.h"
#include "quiche/quic/platform/api/quic_bug_tracker.h"
#include "quiche/quic/platform/api/quic_ip_address.h"
#include "quiche/quic/platform/api/quic_logging.h"
#include "quiche/quic/platform/api/quic_socket_address.h"
#include "quiche/quic/tools/quic_backend_response.h"
#include "quiche/quic/tools/quic_simple_server_backend.h"
#include "quiche/quic/tools/quic_simple_server_session.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_logging.h"
#include "quiche/common/platform/api/quiche_url_utils.h"
#include "quiche/common/quiche_ip_address.h"
#include "quiche/common/quiche_text_utils.h"
namespace quic {
namespace {
AddressAssignCapsule;
AddressRequestCapsule;
Capsule;
IpAddressRange;
PrefixWithId;
RouteAdvertisementCapsule;
class FdWrapper { … };
std::unique_ptr<QuicBackendResponse> CreateBackendErrorResponse(
absl::string_view status, absl::string_view error_details) { … }
}
MasqueServerSession::MasqueServerSession(
MasqueMode masque_mode, const QuicConfig& config,
const ParsedQuicVersionVector& supported_versions,
QuicConnection* connection, QuicSession::Visitor* visitor,
QuicEventLoop* event_loop, QuicCryptoServerStreamBase::Helper* helper,
const QuicCryptoServerConfig* crypto_config,
QuicCompressedCertsCache* compressed_certs_cache,
MasqueServerBackend* masque_server_backend)
: … { … }
void MasqueServerSession::OnMessageAcked(QuicMessageId message_id,
QuicTime ) { … }
void MasqueServerSession::OnMessageLost(QuicMessageId message_id) { … }
void MasqueServerSession::OnConnectionClosed(
const QuicConnectionCloseFrame& frame, ConnectionCloseSource source) { … }
void MasqueServerSession::OnStreamClosed(QuicStreamId stream_id) { … }
std::unique_ptr<QuicBackendResponse>
MasqueServerSession::MaybeCheckConcealedAuth(
const quiche::HttpHeaderBlock& request_headers, absl::string_view authority,
absl::string_view scheme,
QuicSimpleServerBackend::RequestHandler* request_handler) { … }
std::unique_ptr<QuicBackendResponse> MasqueServerSession::HandleMasqueRequest(
const quiche::HttpHeaderBlock& request_headers,
QuicSimpleServerBackend::RequestHandler* request_handler) { … }
void MasqueServerSession::OnSocketEvent(QuicEventLoop* ,
QuicUdpSocketFd fd,
QuicSocketEventMask events) { … }
bool MasqueServerSession::HandleConnectUdpSocketEvent(
QuicUdpSocketFd fd, QuicSocketEventMask events) { … }
bool MasqueServerSession::HandleConnectIpSocketEvent(
QuicUdpSocketFd fd, QuicSocketEventMask events) { … }
bool MasqueServerSession::HandleConnectEthernetSocketEvent(
QuicUdpSocketFd fd, QuicSocketEventMask events) { … }
bool MasqueServerSession::OnSettingsFrame(const SettingsFrame& frame) { … }
MasqueServerSession::ConnectUdpServerState::ConnectUdpServerState(
QuicSpdyStream* stream, const QuicSocketAddress& target_server_address,
QuicUdpSocketFd fd, MasqueServerSession* masque_session)
: … { … }
MasqueServerSession::ConnectUdpServerState::~ConnectUdpServerState() { … }
MasqueServerSession::ConnectUdpServerState::ConnectUdpServerState(
MasqueServerSession::ConnectUdpServerState&& other) { … }
MasqueServerSession::ConnectUdpServerState&
MasqueServerSession::ConnectUdpServerState::operator=(
MasqueServerSession::ConnectUdpServerState&& other) { … }
void MasqueServerSession::ConnectUdpServerState::OnHttp3Datagram(
QuicStreamId stream_id, absl::string_view payload) { … }
MasqueServerSession::ConnectIpServerState::ConnectIpServerState(
QuicIpAddress client_ip, QuicSpdyStream* stream, QuicUdpSocketFd fd,
MasqueServerSession* masque_session)
: … { … }
MasqueServerSession::ConnectIpServerState::~ConnectIpServerState() { … }
MasqueServerSession::ConnectIpServerState::ConnectIpServerState(
MasqueServerSession::ConnectIpServerState&& other) { … }
MasqueServerSession::ConnectIpServerState&
MasqueServerSession::ConnectIpServerState::operator=(
MasqueServerSession::ConnectIpServerState&& other) { … }
void MasqueServerSession::ConnectIpServerState::OnHttp3Datagram(
QuicStreamId stream_id, absl::string_view payload) { … }
bool MasqueServerSession::ConnectIpServerState::OnAddressAssignCapsule(
const AddressAssignCapsule& capsule) { … }
bool MasqueServerSession::ConnectIpServerState::OnAddressRequestCapsule(
const AddressRequestCapsule& capsule) { … }
bool MasqueServerSession::ConnectIpServerState::OnRouteAdvertisementCapsule(
const RouteAdvertisementCapsule& capsule) { … }
void MasqueServerSession::ConnectIpServerState::OnHeadersWritten() { … }
MasqueServerSession::ConnectEthernetServerState::ConnectEthernetServerState(
QuicSpdyStream* stream, QuicUdpSocketFd fd,
MasqueServerSession* masque_session)
: … { … }
MasqueServerSession::ConnectEthernetServerState::~ConnectEthernetServerState() { … }
MasqueServerSession::ConnectEthernetServerState::ConnectEthernetServerState(
MasqueServerSession::ConnectEthernetServerState&& other) { … }
MasqueServerSession::ConnectEthernetServerState&
MasqueServerSession::ConnectEthernetServerState::operator=(
MasqueServerSession::ConnectEthernetServerState&& other) { … }
void MasqueServerSession::ConnectEthernetServerState::OnHttp3Datagram(
QuicStreamId stream_id, absl::string_view payload) { … }
}