From c975384d2262bdcdb7a7237796b52222f1ff5f28 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Thu, 25 Apr 2024 08:00:15 +0800 Subject: [PATCH] Fix quic proxy uri specification --- src/net/tools/naive/naive_proxy_bin.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/net/tools/naive/naive_proxy_bin.cc b/src/net/tools/naive/naive_proxy_bin.cc index 879e2c21b5..dcd8d33146 100644 --- a/src/net/tools/naive/naive_proxy_bin.cc +++ b/src/net/tools/naive/naive_proxy_bin.cc @@ -479,9 +479,24 @@ std::unique_ptr BuildURLRequestContext( builder.DisableHttpCache(); builder.set_net_log(net_log); + std::string proxy_url = params.proxy_url; + bool force_quic = false; + if (proxy_url.compare(0, 7, "quic://") == 0) { + proxy_url.replace(0, 4, "https"); + force_quic = true; + } + ProxyConfig proxy_config; - proxy_config.proxy_rules().ParseFromString(params.proxy_url); - LOG(INFO) << "Proxying via " << params.proxy_url; + proxy_config.proxy_rules().ParseFromString(proxy_url); + if (force_quic) { + const ProxyServer& proxy_server = + proxy_config.proxy_rules().single_proxies.First().First(); + proxy_config.proxy_rules().single_proxies.SetSingleProxyChain( + ProxyChain::ForIpProtection({ProxyServer( + ProxyServer::Scheme::SCHEME_QUIC, proxy_server.host_port_pair())})); + } + LOG(INFO) << "Proxying via " + << proxy_config.proxy_rules().single_proxies.ToDebugString(); auto proxy_service = ConfiguredProxyResolutionService::CreateWithoutProxyResolver( std::make_unique( @@ -507,11 +522,8 @@ std::unique_ptr BuildURLRequestContext( !params.proxy_pass.empty()) { auto* session = context->http_transaction_factory()->GetSession(); auto* auth_cache = session->http_auth_cache(); - std::string proxy_url = params.proxy_url; GURL proxy_gurl(proxy_url); - if (proxy_url.compare(0, 7, "quic://") == 0) { - proxy_url.replace(0, 4, "https"); - proxy_gurl = GURL(proxy_url); + if (force_quic) { auto* quic = context->quic_context()->params(); quic->supported_versions = {quic::ParsedQuicVersion::RFCv1()}; quic->origins_to_force_quic_on.insert(