Merge branch 'domains-end-with-a-dot' into to-esm-modules

This commit is contained in:
ilyaigpetrov 2023-05-03 20:13:48 +05:00
commit bb14665ea3
3 changed files with 38 additions and 24 deletions

View File

@ -306,12 +306,12 @@
if (self.ifProxyMoreDomains) { if (self.ifProxyMoreDomains) {
self.moreDomains = [ self.moreDomains = [
/* Networks */ /* Networks */
'onion', 'i2p', 'onion.', 'i2p.',
/* OpenNIC */ /* OpenNIC */
'bbs', 'chan', 'dyn', 'free', 'geek', 'gopher', 'indy', 'bbs.', 'chan.', 'dyn.', 'free.', 'geek.', 'gopher.', 'indy.',
'libre', 'neo', 'null', 'o', 'oss', 'oz', 'parody', 'pirate', 'libre.', 'neo.', 'null.', 'o.', 'oss.', 'oz.', 'parody.', 'pirate.',
/* OpenNIC Alternatives */ /* OpenNIC Alternatives */
'bazar', 'bit', 'coin', 'emc', 'fur', 'ku', 'lib', 'te', 'ti', 'uu' 'bazar.', 'bit.', 'coin.', 'emc.', 'fur.', 'ku.', 'lib.', 'te.', 'ti.', 'uu.',
]; ];
} }
if (self.ifMindExceptions && self.exceptions) { if (self.ifMindExceptions && self.exceptions) {
@ -364,7 +364,7 @@
/******/ /******/
/******/ const originalFindProxyForURL = FindProxyForURL; /******/ const originalFindProxyForURL = FindProxyForURL;
/******/ let tmp = function(url, host) { /******/ let tmp = function(url, host) {
/******/ const dotHost = '.' + host; /******/ const dotHostDot = '.' + host + (host.endsWith('.') ? '' : '.');
${ ${
function() { function() {
let generatedPac = ` let generatedPac = `
@ -373,7 +373,7 @@
/******/ ${JSON.stringify(pacMods.whitelist)}.some((whiteHost) => { /******/ ${JSON.stringify(pacMods.whitelist)}.some((whiteHost) => {
/******/ const ifWild = whiteHost.startsWith('*'); /******/ const ifWild = whiteHost.startsWith('*');
/******/ if (ifWild) { /******/ if (ifWild) {
/******/ return dotHost.endsWith(whiteHost.substr(1)); /******/ return dotHostDot.endsWith(whiteHost.substr(1));
/******/ } /******/ }
/******/ return host === whiteHost; /******/ return host === whiteHost;
/******/ }) /******/ })
@ -418,9 +418,6 @@
/******/`; /******/`;
} }
const ifIncluded = pacMods.included && pacMods.included.length;
const ifExcluded = pacMods.excluded && pacMods.excluded.length;
const ifManualExceptions = ifIncluded || ifExcluded;
let finalExceptions = {}; let finalExceptions = {};
if (pacMods.ifProxyMoreDomains) { if (pacMods.ifProxyMoreDomains) {
finalExceptions = pacMods.moreDomains.reduce((acc, tld) => { finalExceptions = pacMods.moreDomains.reduce((acc, tld) => {
@ -440,19 +437,19 @@
/******/ /******/
/******/ /* EXCEPTIONS START */ /******/ /* EXCEPTIONS START */
// TODO: handle wildcards. // TODO: handle wildcards.
/******/ const isHostInDomain = (domain, ifWild) => { /******/ const isHostInDomain = (suffix, ifWild) => {
if (ifWild) { if (ifWild) {
return dotHost.endsWith(domain.substr(1)); return dotHostDot.endsWith(suffix.substr(1));
} }
return domain === host; return suffix === host;
} }
/******/ const domainReducer = (maxWeight, [domain, ifProxy]) => { /******/ const domainReducer = (maxWeight, [suffix, ifProxy]) => {
/******/ /******/
const ifWild = domain.startsWith('*.'); const ifWild = suffix.startsWith('*.');
/******/ if (!isHostInDomain(domain, ifWild)) { /******/ if (!isHostInDomain(suffix, ifWild)) {
/******/ return maxWeight; /******/ return maxWeight;
/******/ } /******/ }
let len = domain.length; let len = suffix.length;
if (ifWild) { if (ifWild) {
len = len === 0 ? len : (len - 2)*2 - 1; len = len === 0 ? len : (len - 2)*2 - 1;
} else { } else {

View File

@ -677,13 +677,29 @@
console.log('Updating from', oldAntiCensorRu.version, 'to', antiCensorRu.version); console.log('Updating from', oldAntiCensorRu.version, 'to', antiCensorRu.version);
try { try {
if (window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.57')) { switch(true) {
case window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.57'): {
const azWithPort = 'https://antizapret.prostovpn.org:8443/proxy.pac'; const azWithPort = 'https://antizapret.prostovpn.org:8443/proxy.pac';
const azWithPortAlt = 'https://antizapret.prostovpn.org:18443/proxy.pac'; const azWithPortAlt = 'https://antizapret.prostovpn.org:18443/proxy.pac';
const urls = window.apis.antiCensorRu.pacProviders['Антизапрет'].pacUrls; const urls = window.apis.antiCensorRu.pacProviders['Антизапрет'].pacUrls;
urls[0] = 'https://antizapret.prostovpn.org/proxy.pac'; urls[0] = 'https://antizapret.prostovpn.org/proxy.pac';
urls.unshift(azWithPort, azWithPortAlt); urls.unshift(azWithPort, azWithPortAlt);
console.log('Successfully updated to 0.0.1.58.'); console.log('Successfully updated to 0.0.1.58.');
}; // Fallthrough.
case window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.59'): {
const mods = backgroundPage.apis.pacKitchen.getCurrentConfigs(true);
for(const host of Object.keys(mods.exceptions)) {
if (!host.endsWith('.')) {
const ifProxy = self.exceptions[host] || false;
delete self.exceptions[host];
self.exceptions[\`\${host}.\`] = ifProxy;
}
}
await new Promise((resolve, reject) => keepCookedNowAsync(mods,
(err) => err ? reject(err) : resolve()),
);
console.log('Successfully updated to 0.0.1.60.');
}; // Fallthrough.
} }
} catch (e) { } catch (e) {
// Log update error. // Log update error.

View File

@ -54,6 +54,7 @@ ${(mods.whitelist || []).join('\n')}
.trim() .trim()
.split(/(?:\s*\r?\n\s*)+/g) .split(/(?:\s*\r?\n\s*)+/g)
.filter((host) => host) .filter((host) => host)
.map((host) => host.endsWith('.') ? host : `${host}.`)
) )
dontProxyList = dontProxyList || []; dontProxyList = dontProxyList || [];
whitelist = whitelist || []; whitelist = whitelist || [];