Bug 1743022 - Rename network.trr.blacklist-duration to network.trr.temp_blocklist_durations_sec r=necko-reviewers,kershaw

Also turns it into a static pref r=#necko

Differential Revision: https://phabricator.services.mozilla.com/D136530
This commit is contained in:
Valentin Gosu 2022-01-25 15:57:03 +00:00
parent 87fe62a8ba
commit f2ce1bed77
8 changed files with 14 additions and 35 deletions

View File

@ -10189,6 +10189,13 @@
value: true
mirror: always
# TRR blocklist entry expire time (in seconds). Default is one minute.
# Meant to survive basically a page load.
- name: network.trr.temp_blocklist_duration_sec
type: RelaxedAtomicUint32
value: 60
mirror: always
# Single TRR request timeout, in milliseconds
- name: network.trr.request_timeout_ms
type: RelaxedAtomicUint32

View File

@ -3949,9 +3949,6 @@ pref("network.trr.custom_uri", "");
// Before TRR is widely used the NS record for this host is fetched
// from the DOH end point to ensure proper configuration
pref("network.trr.confirmationNS", "example.com");
// TRR blacklist entry expire time (in seconds). Default is one minute.
// Meant to survive basically a page load.
pref("network.trr.blacklist-duration", 60);
// Comma separated list of domains that we should not use TRR for
pref("network.trr.excluded-domains", "");
pref("network.trr.builtin-excluded-domains", "localhost,local");

View File

@ -95,7 +95,7 @@ class TRR : public Runnable,
// FailData() must be called to signal that the asynch TRR resolve is
// completed. For failed name resolves ("no such host"), the 'error' it
// passses on in its argument must be NS_ERROR_UNKNOWN_HOST. Other errors
// (if host was blacklisted, there as a bad content-type received, etc)
// (if host was blocklisted, there as a bad content-type received, etc)
// other error codes must be used. This distinction is important for the
// subsequent logic to separate the error reasons.
nsresult FailData(nsresult error);

View File

@ -35,8 +35,7 @@ static const char kDisableIpv6Pref[] = "network.dns.disableIPv6";
#define TRR_PREF_PREFIX "network.trr."
#define TRR_PREF(x) TRR_PREF_PREFIX x
namespace mozilla {
namespace net {
namespace mozilla::net {
StaticRefPtr<nsIThread> sTRRBackgroundThread;
static Atomic<TRRService*> sTRRServicePtr;
@ -356,14 +355,6 @@ nsresult TRRService::ReadPrefs(const char* name) {
Preferences::GetCString(TRR_PREF("bootstrapAddr"), mBootstrapAddr);
clearEntireCache = true;
}
if (!name || !strcmp(name, TRR_PREF("blacklist-duration"))) {
// prefs is given in number of seconds
uint32_t secs;
if (NS_SUCCEEDED(
Preferences::GetUint(TRR_PREF("blacklist-duration"), &secs))) {
mBlocklistDurationSeconds = secs;
}
}
if (!name || !strcmp(name, kDisableIpv6Pref)) {
bool tmp;
if (NS_SUCCEEDED(Preferences::GetBool(kDisableIpv6Pref, &tmp))) {
@ -851,7 +842,8 @@ bool TRRService::IsDomainBlocked(const nsACString& aHost,
// use a unified casing for the hashkey
nsAutoCString hashkey(aHost + aOriginSuffix);
if (auto val = bl->Lookup(hashkey)) {
int32_t until = *val + mBlocklistDurationSeconds;
int32_t until =
*val + int32_t(StaticPrefs::network_trr_temp_blocklist_duration_sec());
int32_t expire = NowInSeconds();
if (until > expire) {
LOG(("Host [%s] is TRR blocklisted\n", nsCString(aHost).get()));
@ -1314,5 +1306,4 @@ void TRRService::InitTRRConnectionInfo() {
}
}
} // namespace net
} // namespace mozilla
} // namespace mozilla::net

View File

@ -119,8 +119,6 @@ class TRRService : public TRRServiceBase,
void AddEtcHosts(const nsTArray<nsCString>&);
bool mInitialized{false};
Atomic<uint32_t, Relaxed> mBlocklistDurationSeconds{60};
Mutex mLock{"TRRService"};
nsCString mPrivateCred; // main thread only

View File

@ -81,7 +81,7 @@ function trr_clear_prefs() {
Services.prefs.clearUserPref("network.trr.useGET");
Services.prefs.clearUserPref("network.trr.confirmationNS");
Services.prefs.clearUserPref("network.trr.bootstrapAddr");
Services.prefs.clearUserPref("network.trr.blacklist-duration");
Services.prefs.clearUserPref("network.trr.temp_blocklist_duration_sec");
Services.prefs.clearUserPref("network.trr.request_timeout_ms");
Services.prefs.clearUserPref("network.trr.request_timeout_mode_trronly_ms");
Services.prefs.clearUserPref("network.trr.disable-ECS");

View File

@ -61,7 +61,7 @@ registerCleanupFunction(() => {
prefs.clearUserPref("network.trr.useGET");
prefs.clearUserPref("network.trr.confirmationNS");
prefs.clearUserPref("network.trr.bootstrapAddr");
prefs.clearUserPref("network.trr.blacklist-duration");
prefs.clearUserPref("network.trr.temp_blocklist_duration_sec");
prefs.clearUserPref("network.trr.request-timeout");
prefs.clearUserPref("network.trr.clear-cache-on-pref-change");
});

View File

@ -215,15 +215,9 @@ avoid-blacklist-and-whitelist:
- netwerk/base/nsURLHelper.cpp
- netwerk/cookie/CookieCommons.h
- netwerk/dns/nsHostRecord.cpp
- netwerk/dns/nsHostResolver.cpp
- netwerk/dns/nsIDNService.cpp
- netwerk/dns/nsIDNService.h
- netwerk/dns/TRR.cpp
- netwerk/dns/TRR.h
- netwerk/dns/TRRServiceChild.cpp
- netwerk/dns/TRRService.cpp
- netwerk/dns/TRRService.h
- netwerk/dns/TRRServiceParent.cpp
- netwerk/ipc/DocumentLoadListener.cpp
- netwerk/protocol/about/nsAboutProtocolHandler.cpp
- netwerk/protocol/http/Http2Session.cpp
@ -240,21 +234,13 @@ avoid-blacklist-and-whitelist:
- netwerk/protocol/websocket/BaseWebSocketChannel.cpp
- netwerk/socket/nsSOCKSSocketProvider.cpp
- netwerk/test/gtest/TestCookie.cpp
- netwerk/test/unit/head_trr.js
- netwerk/test/unit_ipc/test_dns_by_type_resolve_wrap.js
- netwerk/test/unit_ipc/test_trr_httpssvc_wrap.js
- netwerk/test/unit/test_bug396389.js
- netwerk/test/unit/test_bug427957.js
- netwerk/test/unit/test_bug464591.js
- netwerk/test/unit/test_bug479413.js
- netwerk/test/unit/test_cookie_blacklist.js
- netwerk/test/unit/test_dns_by_type_resolve.js
- netwerk/test/unit/test_idn_blacklist.js
- netwerk/test/unit/test_idn_urls.js
- netwerk/test/unit/test_odoh.js
- netwerk/test/unit/test_trr_httpssvc.js
- netwerk/test/unit/test_trr.js
- netwerk/test/unit/test_use_httpssvc.js
- netwerk/url-classifier/AsyncUrlChannelClassifier.cpp
- netwerk/url-classifier/nsChannelClassifier.cpp
- netwerk/url-classifier/nsChannelClassifier.h