Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable mDNS #2116

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions docs/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ These are also available on the `chrome://flags` page.

Feature | Description
-- | --
`Mdns` | Enables mDNS and Service Discovery.
`MinimalReferrers` | Removes all cross-origin referrers and strips same-origin referrers down to the origin. Has lower precedence than `NoCrossOriginReferrers`.
`NoCrossOriginReferrers` | Removes all cross-origin referrers. Has lower precedence than `NoReferrers`.
`NoReferrers` | Removes all referrers.
Expand Down
2 changes: 0 additions & 2 deletions flags.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ chrome_pgo_phase=0
clang_use_chrome_plugins=false
disable_fieldtrial_testing_config=true
enable_hangout_services_extension=false
enable_mdns=false
enable_mse_mpeg2ts_stream_parser=true
enable_nacl=false
enable_reading_list=false
enable_remoting=false
enable_reporting=false
enable_service_discovery=false
enable_widevine=true
exclude_unwind_tables=true
google_api_key=""
Expand Down
99 changes: 99 additions & 0 deletions patches/extra/ungoogled-chromium/add-flag-to-enable-mdns.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
--- a/chrome/browser/ungoogled_flag_entries.h
+++ b/chrome/browser/ungoogled_flag_entries.h
@@ -132,4 +132,8 @@
"Minimal Referrers",
"Removes all cross-origin referrers and strips same-origin referrers down to the origin. Has lower precedence than remove-cross-origin-referrers. ungoogled-chromium flag.",
kOsAll, FEATURE_VALUE_TYPE(features::kMinimalReferrers)},
+ {"enable-mdns",
+ "Enable mDNS",
+ "Enables mDNS and Service Discovery. ungoogled-chromium flag.",
+ kOsAll, FEATURE_VALUE_TYPE(network::features::kMdns)},
#endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_
--- a/net/dns/host_resolver_manager.cc
+++ b/net/dns/host_resolver_manager.cc
@@ -110,6 +110,7 @@
#include "net/log/net_log_with_source.h"
#include "net/socket/client_socket_factory.h"
#include "net/url_request/url_request_context.h"
+#include "services/network/public/cpp/features.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "url/scheme_host_port.h"
@@ -179,6 +180,8 @@ bool ContainsIcannNameCollisionIp(const

// True if |hostname| ends with either ".local" or ".local.".
bool ResemblesMulticastDNSName(base::StringPiece hostname) {
+ if (!base::FeatureList::IsEnabled(network::features::kMdns))
+ return false;
return base::EndsWith(hostname, ".local") ||
base::EndsWith(hostname, ".local.");
}
--- a/net/dns/mdns_client_impl.cc
+++ b/net/dns/mdns_client_impl.cc
@@ -26,6 +26,7 @@
#include "net/dns/public/util.h"
#include "net/dns/record_rdata.h"
#include "net/socket/datagram_socket.h"
+#include "services/network/public/cpp/features.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

// TODO(gene): Remove this temporary method of disabling NSEC support once it
@@ -455,6 +456,8 @@ MDnsClientImpl::~MDnsClientImpl() {
}

int MDnsClientImpl::StartListening(MDnsSocketFactory* socket_factory) {
+ if (!base::FeatureList::IsEnabled(network::features::kMdns))
+ return ERR_ABORTED;
DCHECK(!core_.get());
core_ = std::make_unique<Core>(clock_, cleanup_timer_.get());
int rv = core_->Init(socket_factory);
--- a/services/network/p2p/socket_manager.cc
+++ b/services/network/p2p/socket_manager.cc
@@ -8,6 +8,7 @@

#include <utility>

+#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
@@ -29,6 +30,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/abseil-cpp/absl/types/optional.h"
#include "third_party/webrtc/media/base/rtp_utils.h"
@@ -114,7 +116,7 @@ class P2PSocketManager::DnsRequest {
net::HostPortPair host(host_name_, 0);

net::HostResolver::ResolveHostParameters parameters;
- if (enable_mdns_ && HasLocalTld(host_name_)) {
+ if (enable_mdns_ && HasLocalTld(host_name_) && base::FeatureList::IsEnabled(features::kMdns)) {
#if BUILDFLAG(ENABLE_MDNS)
// HostResolver/MDnsClient expects a key without a trailing dot.
host.set_host(host_name_.substr(0, host_name_.size() - 1));
--- a/services/network/public/cpp/features.cc
+++ b/services/network/public/cpp/features.cc
@@ -14,6 +14,10 @@

namespace network::features {

+BASE_FEATURE(kMdns,
+ "Mdns",
+ base::FEATURE_DISABLED_BY_DEFAULT);
+
BASE_FEATURE(kNetworkErrorLogging,
"NetworkErrorLogging",
base::FEATURE_ENABLED_BY_DEFAULT);
--- a/services/network/public/cpp/features.h
+++ b/services/network/public/cpp/features.h
@@ -13,6 +13,7 @@
namespace network {
namespace features {

+COMPONENT_EXPORT(NETWORK_CPP) BASE_DECLARE_FEATURE(kMdns);
COMPONENT_EXPORT(NETWORK_CPP) BASE_DECLARE_FEATURE(kNetworkErrorLogging);
COMPONENT_EXPORT(NETWORK_CPP) BASE_DECLARE_FEATURE(kReporting);
COMPONENT_EXPORT(NETWORK_CPP) BASE_DECLARE_FEATURE(kThrottleDelayable);

This file was deleted.

2 changes: 1 addition & 1 deletion patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ extra/ungoogled-chromium/remove-disable-setuid-sandbox-as-bad-flag.patch
extra/ungoogled-chromium/disable-intranet-redirect-detector.patch
extra/ungoogled-chromium/enable-page-saving-on-more-pages.patch
extra/ungoogled-chromium/disable-download-quarantine.patch
extra/ungoogled-chromium/fix-building-without-mdns-and-service-discovery.patch
extra/ungoogled-chromium/add-flag-to-configure-extension-downloading.patch
extra/ungoogled-chromium/add-flag-for-search-engine-collection.patch
extra/ungoogled-chromium/add-flag-to-disable-beforeunload.patch
Expand Down Expand Up @@ -104,3 +103,4 @@ extra/ungoogled-chromium/add-flags-for-referrer-customization.patch
extra/ungoogled-chromium/default-webrtc-ip-handling-policy.patch
extra/ungoogled-chromium/add-flags-for-existing-switches.patch
extra/ungoogled-chromium/first-run-page.patch
extra/ungoogled-chromium/add-flag-to-enable-mdns.patch