From ad18a0d7ef57fb1ba4115adb7361a6f1c973dd0b Mon Sep 17 00:00:00 2001 From: Eloston Date: Sun, 30 Oct 2022 19:09:18 +0000 Subject: [PATCH] Rebase to 107 and address feedback --- .../add-flag-to-disable-mdns.patch | 191 +++--------------- 1 file changed, 26 insertions(+), 165 deletions(-) diff --git a/patches/extra/ungoogled-chromium/add-flag-to-disable-mdns.patch b/patches/extra/ungoogled-chromium/add-flag-to-disable-mdns.patch index f7bf3f07ec..2588b6a5a0 100644 --- a/patches/extra/ungoogled-chromium/add-flag-to-disable-mdns.patch +++ b/patches/extra/ungoogled-chromium/add-flag-to-disable-mdns.patch @@ -1,134 +1,3 @@ ---- a/chrome/browser/devtools/BUILD.gn -+++ b/chrome/browser/devtools/BUILD.gn -@@ -107,6 +107,7 @@ static_library("devtools") { - "//components/paint_preview/buildflags:buildflags", - "//content/public/browser", - "//net", -+ "//services/network/public/cpp", - "//services/viz/privileged/mojom/compositing", - "//third_party/blink/public:buildflags", - "//ui/events:dom_keycode_converter", ---- a/chrome/browser/devtools/device/devtools_android_bridge.cc -+++ b/chrome/browser/devtools/device/devtools_android_bridge.cc -@@ -17,6 +17,7 @@ - #include "base/callback_helpers.h" - #include "base/command_line.h" - #include "base/compiler_specific.h" -+#include "base/feature_list.h" - #include "base/json/json_reader.h" - #include "base/lazy_instance.h" - #include "base/memory/singleton.h" -@@ -44,6 +45,7 @@ - #include "content/public/browser/devtools_external_agent_proxy_delegate.h" - #include "net/base/host_port_pair.h" - #include "net/base/net_errors.h" -+#include "services/network/public/cpp/features.h" - - #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) - #include "chrome/browser/devtools/device/cast_device_provider.h" -@@ -372,7 +374,9 @@ void DevToolsAndroidBridge::CreateDevice - device_providers.push_back(provider); - - #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) -- device_providers.push_back(new CastDeviceProvider()); -+ if (!base::FeatureList::IsEnabled(network::features::kDisableMdns)) { -+ device_providers.push_back(new CastDeviceProvider()); -+ } - #endif - - device_providers.push_back(new AdbDeviceProvider()); ---- a/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.cc -+++ b/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.cc -@@ -4,7 +4,9 @@ - - #include "chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.h" - -+#include "base/feature_list.h" - #include "chrome/browser/media/router/discovery/mdns/dns_sd_delegate.h" -+#include "services/network/public/cpp/features.h" - - using local_discovery::ServiceDescription; - -@@ -28,7 +30,8 @@ DnsSdDeviceLister::DnsSdDeviceLister( - local_discovery::ServiceDiscoveryClient* service_discovery_client, - DnsSdDelegate* delegate, - const std::string& service_type) -- : delegate_(delegate) -+ : delegate_(delegate), -+ enable_mdns_(!base::FeatureList::IsEnabled(network::features::kDisableMdns)) - #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) - , - service_discovery_client_(service_discovery_client), -@@ -41,36 +44,46 @@ DnsSdDeviceLister::~DnsSdDeviceLister() - - void DnsSdDeviceLister::Discover() { - #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) -- if (!device_lister_) { -- device_lister_ = local_discovery::ServiceDiscoveryDeviceLister::Create( -- this, service_discovery_client_, service_type_); -- device_lister_->Start(); -+ if (enable_mdns_) { -+ if (!device_lister_) { -+ device_lister_ = local_discovery::ServiceDiscoveryDeviceLister::Create( -+ this, service_discovery_client_, service_type_); -+ device_lister_->Start(); -+ } -+ device_lister_->DiscoverNewDevices(); - } -- device_lister_->DiscoverNewDevices(); - #endif - } - - void DnsSdDeviceLister::Reset() { -- device_lister_.reset(); -+ if (enable_mdns_) { -+ device_lister_.reset(); -+ } - } - - void DnsSdDeviceLister::OnDeviceChanged( - const std::string& service_type, - bool added, - const ServiceDescription& service_description) { -- DnsSdService service; -- FillServiceInfo(service_description, &service); -- delegate_->ServiceChanged(device_lister_->service_type(), added, service); -+ if (enable_mdns_) { -+ DnsSdService service; -+ FillServiceInfo(service_description, &service); -+ delegate_->ServiceChanged(device_lister_->service_type(), added, service); -+ } - } - - void DnsSdDeviceLister::OnDeviceRemoved(const std::string& service_type, - const std::string& service_name) { -- delegate_->ServiceRemoved(service_type, service_name); -+ if (enable_mdns_) { -+ delegate_->ServiceRemoved(service_type, service_name); -+ } - } - - void DnsSdDeviceLister::OnDeviceCacheFlushed(const std::string& service_type) { -- delegate_->ServicesFlushed(device_lister_->service_type()); -- device_lister_->DiscoverNewDevices(); -+ if (enable_mdns_) { -+ delegate_->ServicesFlushed(device_lister_->service_type()); -+ device_lister_->DiscoverNewDevices(); -+ } - } - - } // namespace media_router ---- a/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.h -+++ b/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.h -@@ -57,6 +57,8 @@ class DnsSdDeviceLister - // Created when Discover() is called, if service discovery is enabled. - std::unique_ptr device_lister_; - -+ const bool enable_mdns_; -+ - #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) - // The client and service type used to create |device_lister_|. - const raw_ptr --- a/chrome/browser/ungoogled_flag_entries.h +++ b/chrome/browser/ungoogled_flag_entries.h @@ -116,4 +116,8 @@ @@ -150,7 +19,7 @@ #include "base/memory/scoped_refptr.h" #include "base/metrics/histogram_functions.h" #include "base/time/time.h" -@@ -13,6 +14,7 @@ +@@ -14,6 +15,7 @@ #include "net/base/ip_endpoint.h" #include "net/http/http_response_headers.h" #include "net/net_buildflags.h" @@ -158,42 +27,34 @@ #include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/simple_url_loader.h" #include "services/network/public/mojom/network_context.mojom.h" -@@ -90,7 +92,7 @@ void ResolveHostAndOpenSocket::Start() { - network::mojom::ResolveHostParametersPtr parameters = - network::mojom::ResolveHostParameters::New(); +@@ -31,6 +33,9 @@ constexpr int kHttpsPort = 443; + #if BUILDFLAG(ENABLE_MDNS) -- if (ResemblesMulticastDNSName(*options_->remote_hostname)) { -+ if (!base::FeatureList::IsEnabled(network::features::kDisableMdns) && ResemblesMulticastDNSName(*options_->remote_hostname)) { - parameters->source = net::HostResolverSource::MULTICAST_DNS; - is_mdns_name_ = true; - } ---- a/services/network/p2p/socket_manager.cc -+++ b/services/network/p2p/socket_manager.cc -@@ -9,6 +9,7 @@ - #include + bool ResemblesMulticastDNSName(const std::string& hostname) { ++ if (!base::FeatureList::IsEnabled(network::features::kDisableMdns) { ++ return false; ++ } + return base::EndsWith(hostname, ".local") || + base::EndsWith(hostname, ".local."); + } +@@ -368,4 +373,4 @@ void ResolveHostAndOpenUDPSocket::OnUdpC + delete this; + } - #include "base/bind.h" -+#include "base/feature_list.h" - #include "base/memory/raw_ptr.h" - #include "base/task/thread_pool.h" - #include "base/threading/thread_task_runner_handle.h" -@@ -27,6 +28,7 @@ - #include "net/url_request/url_request_context_getter.h" - #include "services/network/p2p/socket.h" - #include "services/network/proxy_resolving_client_socket_factory.h" -+#include "services/network/public/cpp/features.h" - #include "services/network/public/cpp/p2p_param_traits.h" - #include "third_party/webrtc/media/base/rtp_utils.h" - #include "third_party/webrtc/media/base/turn_utils.h" -@@ -103,7 +105,7 @@ class P2PSocketManager::DnsRequest { - net::HostPortPair host(host_name_, 0); +-} // namespace content +\ No newline at end of file ++} // namespace content +--- a/net/dns/mdns_client_impl.cc ++++ b/net/dns/mdns_client_impl.cc +@@ -452,6 +452,8 @@ MDnsClientImpl::~MDnsClientImpl() { + } - net::HostResolver::ResolveHostParameters parameters; -- if (enable_mdns_ && HasLocalTld(host_name_)) { -+ if (enable_mdns_ && HasLocalTld(host_name_) && !base::FeatureList::IsEnabled(features::kDisableMdns)) { - #if BUILDFLAG(ENABLE_MDNS) - // HostResolver/MDnsClient expects a key without a trailing dot. - host.set_host(host_name_.substr(0, host_name_.size() - 1)); + int MDnsClientImpl::StartListening(MDnsSocketFactory* socket_factory) { ++ if (base::FeatureList::IsEnabled(network::features::kDisableMdns)) ++ return ERR_ABORTED; + DCHECK(!core_.get()); + core_ = std::make_unique(clock_, cleanup_timer_.get()); + int rv = core_->Init(socket_factory); --- a/services/network/public/cpp/features.cc +++ b/services/network/public/cpp/features.cc @@ -15,6 +15,9 @@