mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Avoid using dns.resolve() for proxied DNS resolution
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/1743
This commit is contained in:
parent
09ccfc8cfb
commit
d5f14ffa32
3 changed files with 2 additions and 47 deletions
|
@ -19,12 +19,6 @@
|
||||||
Home: https://github.com/gorhill/uBlock
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* globals browser */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
domainFromHostname,
|
domainFromHostname,
|
||||||
hostnameFromNetworkURL,
|
hostnameFromNetworkURL,
|
||||||
|
@ -34,24 +28,6 @@ import {
|
||||||
|
|
||||||
// Canonical name-uncloaking feature.
|
// Canonical name-uncloaking feature.
|
||||||
let cnameUncloakEnabled = browser.dns instanceof Object;
|
let cnameUncloakEnabled = browser.dns instanceof Object;
|
||||||
let cnameUncloakProxied = false;
|
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/911
|
|
||||||
// We detect here whether network requests are proxied, and if so,
|
|
||||||
// de-aliasing of hostnames will be disabled to avoid possible
|
|
||||||
// DNS leaks.
|
|
||||||
const proxyDetector = function(details) {
|
|
||||||
if ( details.proxyInfo instanceof Object ) {
|
|
||||||
cnameUncloakEnabled = false;
|
|
||||||
proxyDetectorTryCount = 0;
|
|
||||||
}
|
|
||||||
if ( proxyDetectorTryCount === 0 ) {
|
|
||||||
browser.webRequest.onHeadersReceived.removeListener(proxyDetector);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
proxyDetectorTryCount -= 1;
|
|
||||||
};
|
|
||||||
let proxyDetectorTryCount = 0;
|
|
||||||
|
|
||||||
// Related issues:
|
// Related issues:
|
||||||
// - https://github.com/gorhill/uBlock/issues/1327
|
// - https://github.com/gorhill/uBlock/issues/1327
|
||||||
|
@ -81,9 +57,6 @@ vAPI.Net = class extends vAPI.Net {
|
||||||
this.canUncloakCnames &&
|
this.canUncloakCnames &&
|
||||||
options.cnameUncloakEnabled !== false;
|
options.cnameUncloakEnabled !== false;
|
||||||
}
|
}
|
||||||
if ( 'cnameUncloakProxied' in options ) {
|
|
||||||
cnameUncloakProxied = options.cnameUncloakProxied === true;
|
|
||||||
}
|
|
||||||
if ( 'cnameIgnoreList' in options ) {
|
if ( 'cnameIgnoreList' in options ) {
|
||||||
this.cnameIgnoreList =
|
this.cnameIgnoreList =
|
||||||
this.regexFromStrList(options.cnameIgnoreList);
|
this.regexFromStrList(options.cnameIgnoreList);
|
||||||
|
@ -108,23 +81,6 @@ vAPI.Net = class extends vAPI.Net {
|
||||||
}
|
}
|
||||||
this.cnames.clear(); this.cnames.set('', null);
|
this.cnames.clear(); this.cnames.set('', null);
|
||||||
this.cnameFlushTime = Date.now() + this.cnameMaxTTL * 60000;
|
this.cnameFlushTime = Date.now() + this.cnameMaxTTL * 60000;
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/911
|
|
||||||
// Install/remove proxy detector.
|
|
||||||
if ( vAPI.webextFlavor.major < 80 ) {
|
|
||||||
const wrohr = browser.webRequest.onHeadersReceived;
|
|
||||||
if ( cnameUncloakEnabled === false || cnameUncloakProxied ) {
|
|
||||||
if ( wrohr.hasListener(proxyDetector) ) {
|
|
||||||
wrohr.removeListener(proxyDetector);
|
|
||||||
}
|
|
||||||
} else if ( wrohr.hasListener(proxyDetector) === false ) {
|
|
||||||
wrohr.addListener(
|
|
||||||
proxyDetector,
|
|
||||||
{ urls: [ '*://*/*' ] },
|
|
||||||
[ 'blocking' ]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
proxyDetectorTryCount = 32;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
normalizeDetails(details) {
|
normalizeDetails(details) {
|
||||||
const type = details.type;
|
const type = details.type;
|
||||||
|
@ -236,7 +192,7 @@ vAPI.Net = class extends vAPI.Net {
|
||||||
return /^./;
|
return /^./;
|
||||||
}
|
}
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
'(?:^|\.)(?:' +
|
'(?:^|\\.)(?:' +
|
||||||
list.trim()
|
list.trim()
|
||||||
.split(/\s+/)
|
.split(/\s+/)
|
||||||
.map(a => a.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
.map(a => a.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
||||||
|
@ -261,6 +217,7 @@ vAPI.Net = class extends vAPI.Net {
|
||||||
if ( cnRecord !== undefined ) {
|
if ( cnRecord !== undefined ) {
|
||||||
return this.processCanonicalName(hn, cnRecord, details);
|
return this.processCanonicalName(hn, cnRecord, details);
|
||||||
}
|
}
|
||||||
|
if ( details.proxyInfo && details.proxyInfo.proxyDNS ) { return; }
|
||||||
const documentUrl = details.documentUrl || details.url;
|
const documentUrl = details.documentUrl || details.url;
|
||||||
const isRootDocument = this.cnameIgnoreRootDocument &&
|
const isRootDocument = this.cnameIgnoreRootDocument &&
|
||||||
hn === hostnameFromNetworkURL(documentUrl);
|
hn === hostnameFromNetworkURL(documentUrl);
|
||||||
|
|
|
@ -61,7 +61,6 @@ const hiddenSettingsDefault = {
|
||||||
cnameIgnoreRootDocument: true,
|
cnameIgnoreRootDocument: true,
|
||||||
cnameMaxTTL: 120,
|
cnameMaxTTL: 120,
|
||||||
cnameReplayFullURL: false,
|
cnameReplayFullURL: false,
|
||||||
cnameUncloakProxied: false,
|
|
||||||
consoleLogLevel: 'unset',
|
consoleLogLevel: 'unset',
|
||||||
debugAssetsJson: false,
|
debugAssetsJson: false,
|
||||||
debugScriptlets: false,
|
debugScriptlets: false,
|
||||||
|
|
|
@ -319,7 +319,6 @@ onBroadcast(msg => {
|
||||||
cnameIgnoreRootDocument: µbhs.cnameIgnoreRootDocument,
|
cnameIgnoreRootDocument: µbhs.cnameIgnoreRootDocument,
|
||||||
cnameMaxTTL: µbhs.cnameMaxTTL,
|
cnameMaxTTL: µbhs.cnameMaxTTL,
|
||||||
cnameReplayFullURL: µbhs.cnameReplayFullURL,
|
cnameReplayFullURL: µbhs.cnameReplayFullURL,
|
||||||
cnameUncloakProxied: µbhs.cnameUncloakProxied,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue