#include "quiche/quic/tools/connect_udp_tunnel.h"
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "absl/container/flat_hash_set.h"
#include "absl/status/status.h"
#include "absl/status/statusor.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 "absl/types/span.h"
#include "quiche/quic/core/quic_error_codes.h"
#include "quiche/quic/core/quic_server_id.h"
#include "quiche/quic/core/socket_factory.h"
#include "quiche/quic/platform/api/quic_socket_address.h"
#include "quiche/quic/tools/quic_backend_response.h"
#include "quiche/quic/tools/quic_name_lookup.h"
#include "quiche/quic/tools/quic_simple_server_backend.h"
#include "quiche/common/http/http_header_block.h"
#include "quiche/common/masque/connect_udp_datagram_payload.h"
#include "quiche/common/platform/api/quiche_googleurl.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/platform/api/quiche_mem_slice.h"
#include "quiche/common/platform/api/quiche_url_utils.h"
#include "quiche/common/structured_headers.h"
namespace quic {
structured_headers;
namespace {
constexpr size_t kReadSize = …;
std::optional<QuicServerId> ValidateAndParseTargetFromPath(
absl::string_view path) { … }
std::optional<QuicServerId> ValidateHeadersAndGetTarget(
const quiche::HttpHeaderBlock& request_headers) { … }
bool ValidateTarget(
const QuicServerId& target,
const absl::flat_hash_set<QuicServerId>& acceptable_targets) { … }
}
ConnectUdpTunnel::ConnectUdpTunnel(
QuicSimpleServerBackend::RequestHandler* client_stream_request_handler,
SocketFactory* socket_factory, std::string server_label,
absl::flat_hash_set<QuicServerId> acceptable_targets)
: … { … }
ConnectUdpTunnel::~ConnectUdpTunnel() { … }
void ConnectUdpTunnel::OpenTunnel(
const quiche::HttpHeaderBlock& request_headers) { … }
bool ConnectUdpTunnel::IsTunnelOpenToTarget() const { … }
void ConnectUdpTunnel::OnClientStreamClose() { … }
void ConnectUdpTunnel::ConnectComplete(absl::Status ) { … }
void ConnectUdpTunnel::ReceiveComplete(
absl::StatusOr<quiche::QuicheMemSlice> data) { … }
void ConnectUdpTunnel::SendComplete(absl::Status ) { … }
void ConnectUdpTunnel::OnHttp3Datagram(QuicStreamId stream_id,
absl::string_view payload) { … }
void ConnectUdpTunnel::BeginAsyncReadFromTarget() { … }
void ConnectUdpTunnel::SendUdpPacketToTarget(absl::string_view packet) { … }
void ConnectUdpTunnel::SendConnectResponse() { … }
void ConnectUdpTunnel::SendErrorResponse(absl::string_view status,
absl::string_view proxy_status_error,
absl::string_view error_details) { … }
void ConnectUdpTunnel::TerminateClientStream(
absl::string_view error_description, QuicResetStreamError error_code) { … }
}