mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-11-24 06:16:30 +03:00
cronet: Use fixed proxy resolution from experimental option proxy_server
This commit is contained in:
parent
7e1b26f0fc
commit
9d7164a2c4
@ -12,6 +12,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/base64.h"
|
#include "base/base64.h"
|
||||||
@ -53,7 +54,10 @@
|
|||||||
#include "net/log/net_log_util.h"
|
#include "net/log/net_log_util.h"
|
||||||
#include "net/net_buildflags.h"
|
#include "net/net_buildflags.h"
|
||||||
#include "net/nqe/network_quality_estimator_params.h"
|
#include "net/nqe/network_quality_estimator_params.h"
|
||||||
|
#include "net/proxy_resolution/configured_proxy_resolution_service.h"
|
||||||
|
#include "net/proxy_resolution/proxy_config.h"
|
||||||
#include "net/proxy_resolution/proxy_config_service_fixed.h"
|
#include "net/proxy_resolution/proxy_config_service_fixed.h"
|
||||||
|
#include "net/proxy_resolution/proxy_config_with_annotation.h"
|
||||||
#include "net/proxy_resolution/proxy_resolution_service.h"
|
#include "net/proxy_resolution/proxy_resolution_service.h"
|
||||||
#include "net/third_party/quiche/src/quic/core/quic_versions.h"
|
#include "net/third_party/quiche/src/quic/core/quic_versions.h"
|
||||||
#include "net/url_request/url_request_context.h"
|
#include "net/url_request/url_request_context.h"
|
||||||
@ -352,9 +356,25 @@ CronetContext::NetworkTasks::BuildDefaultURLRequestContext(
|
|||||||
net::URLRequestContextBuilder context_builder;
|
net::URLRequestContextBuilder context_builder;
|
||||||
SetSharedURLRequestContextBuilderConfig(&context_builder);
|
SetSharedURLRequestContextBuilderConfig(&context_builder);
|
||||||
|
|
||||||
context_builder.set_proxy_resolution_service(
|
const auto proxy_server_it =
|
||||||
cronet::CreateProxyResolutionService(std::move(proxy_config_service),
|
context_config_->effective_experimental_options.find("proxy_server");
|
||||||
g_net_log.Get().net_log()));
|
std::string proxy_server_str = "direct://";
|
||||||
|
if (proxy_server_it !=
|
||||||
|
context_config_->effective_experimental_options.end()) {
|
||||||
|
const base::Value& value = proxy_server_it->second;
|
||||||
|
if (value.is_string()) {
|
||||||
|
proxy_server_str = value.GetString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
net::ProxyConfig proxy_config;
|
||||||
|
proxy_config.proxy_rules().ParseFromString(proxy_server_str);
|
||||||
|
auto proxy_service =
|
||||||
|
net::ConfiguredProxyResolutionService::CreateWithoutProxyResolver(
|
||||||
|
std::make_unique<net::ProxyConfigServiceFixed>(
|
||||||
|
net::ProxyConfigWithAnnotation(proxy_config,
|
||||||
|
MISSING_TRAFFIC_ANNOTATION)),
|
||||||
|
g_net_log.Get().net_log());
|
||||||
|
context_builder.set_proxy_resolution_service(std::move(proxy_service));
|
||||||
|
|
||||||
if (context_config_->enable_network_quality_estimator) {
|
if (context_config_->enable_network_quality_estimator) {
|
||||||
std::unique_ptr<net::NetworkQualityEstimatorParams> nqe_params =
|
std::unique_ptr<net::NetworkQualityEstimatorParams> nqe_params =
|
||||||
|
@ -63,15 +63,13 @@ void PostTaskToInitThread(const base::Location& posted_from,
|
|||||||
|
|
||||||
std::unique_ptr<net::ProxyConfigService> CreateProxyConfigService(
|
std::unique_ptr<net::ProxyConfigService> CreateProxyConfigService(
|
||||||
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) {
|
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) {
|
||||||
return net::ConfiguredProxyResolutionService::CreateSystemProxyConfigService(
|
return nullptr;
|
||||||
io_task_runner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<net::ProxyResolutionService> CreateProxyResolutionService(
|
std::unique_ptr<net::ProxyResolutionService> CreateProxyResolutionService(
|
||||||
std::unique_ptr<net::ProxyConfigService> proxy_config_service,
|
std::unique_ptr<net::ProxyConfigService> proxy_config_service,
|
||||||
net::NetLog* net_log) {
|
net::NetLog* net_log) {
|
||||||
return net::ConfiguredProxyResolutionService::CreateUsingSystemProxyResolver(
|
return nullptr;
|
||||||
std::move(proxy_config_service), net_log, /*quick_check_enabled=*/true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CreateDefaultUserAgent(const std::string& partial_user_agent) {
|
std::string CreateDefaultUserAgent(const std::string& partial_user_agent) {
|
||||||
|
@ -758,6 +758,14 @@ void URLRequestContextConfig::SetContextBuilderExperimentalOptions(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
session_params->spdy_go_away_on_ip_change = iter.second.GetBool();
|
session_params->spdy_go_away_on_ip_change = iter.second.GetBool();
|
||||||
|
} else if (iter.first == "proxy_server") {
|
||||||
|
if (!iter.second.is_string()) {
|
||||||
|
LOG(ERROR) << "\"" << iter.first << "\" config params \"" << iter.second
|
||||||
|
<< "\" is not a string";
|
||||||
|
effective_experimental_options.erase(iter.first);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Handled in CronetContext::NetworkTasks::BuildDefaultURLRequestContext.
|
||||||
} else {
|
} else {
|
||||||
LOG(WARNING) << "Unrecognized Cronet experimental option \"" << iter.first
|
LOG(WARNING) << "Unrecognized Cronet experimental option \"" << iter.first
|
||||||
<< "\" with params \"" << iter.second;
|
<< "\" with params \"" << iter.second;
|
||||||
|
Loading…
Reference in New Issue
Block a user