From 760b2ffce6afe6f428d75482accf09bbd5b28a41 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 19 Sep 2024 08:43:54 -0400 Subject: [PATCH] Add advanced setting `dnsResolveEnabled` Default to `true`. Set to `false` to wholly disable calls to `dns.resolve()` (Firefox- only). Disabling calls to `dns.resolve()` will prevent cname-uncloaking and will limit ability to enforce `ipaddress` filter option. --- platform/firefox/vapi-background-ext.js | 5 +++++ src/js/background.js | 1 + src/js/storage.js | 1 + 3 files changed, 7 insertions(+) diff --git a/platform/firefox/vapi-background-ext.js b/platform/firefox/vapi-background-ext.js index 7fdc3dd55..79787cc99 100644 --- a/platform/firefox/vapi-background-ext.js +++ b/platform/firefox/vapi-background-ext.js @@ -62,6 +62,7 @@ vAPI.Net = class extends vAPI.Net { this.cnameIgnoreExceptions = true; this.cnameIgnoreRootDocument = true; this.cnameReplayFullURL = false; + this.dnsResolveEnabled = true; } setOptions(options) { @@ -89,6 +90,9 @@ vAPI.Net = class extends vAPI.Net { if ( 'cnameReplayFullURL' in options ) { this.cnameReplayFullURL = options.cnameReplayFullURL === true; } + if ( 'dnsResolveEnabled' in options ) { + this.dnsResolveEnabled = options.dnsResolveEnabled === true; + } this.dnsList.fill(null); this.dnsDict.clear(); } @@ -256,6 +260,7 @@ vAPI.Net = class extends vAPI.Net { } dnsShouldResolve(hn) { + if ( this.dnsResolveEnabled === false ) { return false; } if ( hn === '' ) { return false; } const c0 = hn.charCodeAt(0); if ( c0 === 0x5B /* [ */ ) { return false; } diff --git a/src/js/background.js b/src/js/background.js index 939c559c3..8ea668ee9 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -66,6 +66,7 @@ const hiddenSettingsDefault = { debugScriptletInjector: false, differentialUpdate: true, disableWebAssembly: false, + dnsResolveEnabled: true, extensionUpdateForceReload: false, filterAuthorMode: false, loggerPopupType: 'popup', diff --git a/src/js/storage.js b/src/js/storage.js index 77ec90b7d..c04e85c87 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -319,6 +319,7 @@ onBroadcast(msg => { cnameIgnoreRootDocument: µbhs.cnameIgnoreRootDocument, cnameMaxTTL: µbhs.cnameMaxTTL, cnameReplayFullURL: µbhs.cnameReplayFullURL, + dnsResolveEnabled: µbhs.dnsResolveEnabled, }); });