Bug 1565022 - TRR: Check for NRPT on Windows to use platform DNS r=mayhemer

Differential Revision: https://phabricator.services.mozilla.com/D54093

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Valentin Gosu 2019-11-24 14:33:26 +00:00
Родитель 0e928af6c3
Коммит 43afef29e7
4 изменённых файлов: 52 добавлений и 25 удалений

Просмотреть файл

@ -6861,6 +6861,12 @@
value: false
mirror: always
# This pref controls if TRR will still be enabled when NRPT rules are detected
- name: network.trr.enable_when_nrpt_detected
type: RelaxedAtomicBool
value: false
mirror: always
# Allow the network changed event to get sent when a network topology or setup
# change is noticed while running.
- name: network.notify.changed
@ -6891,6 +6897,13 @@
value: true
mirror: always
# Whether to check the registry for NRPT rules on network changes that
# indicate that TRR should not be used.
- name: network.notify.checkForNRPT
type: RelaxedAtomicBool
value: true
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "nglayout."
#---------------------------------------------------------------------------

Просмотреть файл

@ -60,6 +60,7 @@ interface nsINetworkLinkService : nsISupports
const unsigned long NONE_DETECTED = 0;
const unsigned long VPN_DETECTED = 1 << 0;
const unsigned long PROXY_DETECTED = 1 << 1;
const unsigned long NRPT_DETECTED = 1 << 2;
/**
* A bitfield that encodes the platform attributes we detected which

Просмотреть файл

@ -491,7 +491,9 @@ void TRRService::CheckPlatformDNSStatus(nsINetworkLinkService* aLinkService) {
(!StaticPrefs::network_trr_enable_when_vpn_detected() &&
(platformIndications & nsINetworkLinkService::VPN_DETECTED)) ||
(!StaticPrefs::network_trr_enable_when_proxy_detected() &&
(platformIndications & nsINetworkLinkService::PROXY_DETECTED));
(platformIndications & nsINetworkLinkService::PROXY_DETECTED)) ||
(!StaticPrefs::network_trr_enable_when_nrpt_detected() &&
(platformIndications & nsINetworkLinkService::NRPT_DETECTED));
}
void TRRService::MaybeConfirm() {

Просмотреть файл

@ -542,31 +542,31 @@ nsNotifyAddrListener::CheckAdaptersAddresses(void) {
checkRegistry();
}
auto registryChildCount = [](const nsAString& aRegPath) -> uint32_t {
nsresult rv;
nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
if (NS_FAILED(rv)) {
LOG((" creating nsIWindowsRegKey failed\n"));
return 0;
}
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, aRegPath,
nsIWindowsRegKey::ACCESS_READ);
if (NS_FAILED(rv)) {
LOG((" opening registry key failed\n"));
return 0;
}
uint32_t count = 0;
rv = regKey->GetChildCount(&count);
if (NS_FAILED(rv)) {
return 0;
}
return count;
};
if (StaticPrefs::network_notify_checkForProxies()) {
auto registryChildCount = [](const nsAString& aRegPath) -> uint32_t {
nsresult rv;
nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
if (NS_FAILED(rv)) {
LOG((" creating nsIWindowsRegKey failed\n"));
return 0;
}
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, aRegPath,
nsIWindowsRegKey::ACCESS_READ);
if (NS_FAILED(rv)) {
LOG((" opening registry key failed\n"));
return 0;
}
uint32_t count = 0;
rv = regKey->GetChildCount(&count);
if (NS_FAILED(rv)) {
return 0;
}
return count;
};
if (registryChildCount(
NS_LITERAL_STRING("SYSTEM\\CurrentControlSet\\Services\\Dnscache\\"
"Parameters\\DnsConnections")) > 0 ||
@ -577,6 +577,17 @@ nsNotifyAddrListener::CheckAdaptersAddresses(void) {
}
}
if (StaticPrefs::network_notify_checkForNRPT()) {
if (registryChildCount(
NS_LITERAL_STRING("SYSTEM\\CurrentControlSet\\Services\\Dnscache\\"
"Parameters\\DnsPolicyConfig")) > 0 ||
registryChildCount(
NS_LITERAL_STRING("SOFTWARE\\Policies\\Microsoft\\Windows NT\\"
"DNSClient\\DnsPolicyConfig")) > 0) {
platformDNSIndications |= NRPT_DETECTED;
}
}
{
MutexAutoLock lock(mMutex);
mDnsSuffixList.SwapElements(dnsSuffixList);