1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-21 18:02:34 +01:00

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
This commit is contained in:
Raymond Hill 2024-10-02 14:51:26 -04:00
parent 73ce4e6bcf
commit 4305bfbdb1
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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));
}