Bug 1637727 - convert network.security.esni.enabled to a StaticPref. r=KrisWright,necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D77102
This commit is contained in:
Alexis Beingessner 2020-05-28 18:23:20 +00:00
Родитель 4d415be57c
Коммит 2c55bb187c
4 изменённых файлов: 13 добавлений и 16 удалений

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

@ -35,6 +35,7 @@
#include "mozilla/Components.h"
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_network.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -45,7 +46,6 @@ static bool sInitialized = false;
static nsIDNSService* sDNSService = nullptr;
static nsHTMLDNSPrefetch::nsDeferrals* sPrefetches = nullptr;
static nsHTMLDNSPrefetch::nsListener* sDNSListener = nullptr;
bool sEsniEnabled;
nsresult nsHTMLDNSPrefetch::Initialize() {
if (sInitialized) {
@ -61,10 +61,6 @@ nsresult nsHTMLDNSPrefetch::Initialize() {
sPrefetches->Activate();
Preferences::AddBoolVarCache(&sEsniEnabled, "network.security.esni.enabled");
sEsniEnabled = Preferences::GetBool("network.security.esni.enabled", false);
if (IsNeckoChild()) NeckoChild::InitNeckoChild();
sInitialized = true;
@ -166,7 +162,7 @@ nsresult nsHTMLDNSPrefetch::Prefetch(
}
// Fetch ESNI keys if needed.
if (isHttps && sEsniEnabled) {
if (isHttps && StaticPrefs::network_security_esni_enabled()) {
nsAutoCString esniHost;
esniHost.Append("_esni.");
esniHost.Append(NS_ConvertUTF16toUTF8(hostname));
@ -258,7 +254,7 @@ nsresult nsHTMLDNSPrefetch::CancelPrefetch(
NS_ConvertUTF16toUTF8(hostname), flags | nsIDNSService::RESOLVE_SPECULATE,
sDNSListener, aReason, aPartitionedPrincipalOriginAttributes);
// Cancel fetching ESNI keys if needed.
if (sEsniEnabled && isHttps) {
if (StaticPrefs::network_security_esni_enabled() && isHttps) {
nsAutoCString esniHost;
esniHost.Append("_esni.");
esniHost.Append(NS_ConvertUTF16toUTF8(hostname));
@ -411,7 +407,8 @@ void nsHTMLDNSPrefetch::nsDeferrals::SubmitQueue() {
mEntries[mTail].mFlags | nsIDNSService::RESOLVE_SPECULATE,
sDNSListener, nullptr, oa, getter_AddRefs(tmpOutstanding));
// Fetch ESNI keys if needed.
if (NS_SUCCEEDED(rv) && sEsniEnabled && isHttps) {
if (NS_SUCCEEDED(rv) &&
StaticPrefs::network_security_esni_enabled() && isHttps) {
nsAutoCString esniHost;
esniHost.Append("_esni.");
esniHost.Append(hostName);

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

@ -7759,6 +7759,12 @@
value: true
mirror: always
# Whether to use sni encryption.
- name: network.security.esni.enabled
type: bool
value: false
mirror: always
# Single TRR request timeout, in milliseconds
- name: network.trr.request_timeout_ms
type: RelaxedAtomicUint32

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

@ -1577,9 +1577,6 @@ pref("network.sts.max_time_for_pr_close_during_shutdown", 5000);
// The value is expected in seconds.
pref("network.sts.pollable_event_timeout", 6);
// Enable/disable sni encryption.
pref("network.security.esni.enabled", false);
// 2147483647 == PR_INT32_MAX == ~2 GB
pref("network.websocket.max-message-size", 2147483647);

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

@ -90,8 +90,6 @@ static const uint8_t kRollingLoadOffset = 12;
static const int32_t kMaxPrefetchRollingLoadCount = 20;
static const uint32_t kFlagsMask = ((1 << kRollingLoadOffset) - 1);
static bool sEsniEnabled = false;
// ID Extensions for cache entries
#define PREDICTOR_ORIGIN_EXTENSION "predictor-origin"
@ -387,8 +385,6 @@ nsresult Predictor::Init() {
mDnsService = do_GetService("@mozilla.org/network/dns-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
Preferences::AddBoolVarCache(&sEsniEnabled, "network.security.esni.enabled");
mInitialized = true;
return rv;
@ -1200,7 +1196,8 @@ bool Predictor::RunPredictions(nsIURI* referrer,
getter_AddRefs(tmpCancelable));
// Fetch esni keys if needed.
if (sEsniEnabled && uri->SchemeIs("https")) {
if (StaticPrefs::network_security_esni_enabled() &&
uri->SchemeIs("https")) {
nsAutoCString esniHost;
esniHost.Append("_esni.");
esniHost.Append(hostname);