From 4305bfbdb10f7cccd3fabbff11f0510dce794afb Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 2 Oct 2024 14:51:26 -0400 Subject: [PATCH] Skip dns resolution when requests are proxied through http Related issue: https://github.com/uBlockOrigin/uBlock-issues/discussions/3396 Reference: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy/ProxyInfo#type_2 --- platform/firefox/vapi-background-ext.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/firefox/vapi-background-ext.js b/platform/firefox/vapi-background-ext.js index a6032066d..4cf7ec978 100644 --- a/platform/firefox/vapi-background-ext.js +++ b/platform/firefox/vapi-background-ext.js @@ -36,6 +36,8 @@ const isPromise = o => o instanceof Promise; const isResolvedObject = o => o instanceof Object && o instanceof Promise === false; const reIPv4 = /^\d+\.\d+\.\d+\.\d+$/ +const skipDNS = proxyInfo => + proxyInfo?.proxyDNS || proxyInfo?.type?.startsWith('http'); /******************************************************************************/ @@ -102,7 +104,7 @@ vAPI.Net = class extends vAPI.Net { normalizeDetails(details) { // https://github.com/uBlockOrigin/uBlock-issues/issues/3379 - if ( details.proxyInfo?.proxyDNS && details.ip === '0.0.0.0' ) { + if ( skipDNS(details.proxyInfo) && details.ip === '0.0.0.0' ) { details.ip = null; } const type = details.type; @@ -182,8 +184,8 @@ vAPI.Net = class extends vAPI.Net { if ( isResolvedObject(dnsEntry) ) { return this.onAfterDNSResolution(hn, details, dnsEntry); } + if ( skipDNS(details.proxyInfo) ) { return; } if ( this.dnsShouldResolve(hn) === false ) { return; } - if ( details.proxyInfo?.proxyDNS ) { return; } const promise = dnsEntry || this.dnsResolve(hn, details); return promise.then(( ) => this.onAfterDNSResolution(hn, details)); }