diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.mjs b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.mjs index b594500..d1012b1 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.mjs +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.mjs @@ -306,12 +306,12 @@ if (self.ifProxyMoreDomains) { self.moreDomains = [ /* Networks */ - 'onion', 'i2p', + 'onion.', 'i2p.', /* OpenNIC */ - 'bbs', 'chan', 'dyn', 'free', 'geek', 'gopher', 'indy', - 'libre', 'neo', 'null', 'o', 'oss', 'oz', 'parody', 'pirate', + 'bbs.', 'chan.', 'dyn.', 'free.', 'geek.', 'gopher.', 'indy.', + 'libre.', 'neo.', 'null.', 'o.', 'oss.', 'oz.', 'parody.', 'pirate.', /* 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) { @@ -364,7 +364,7 @@ /******/ /******/ const originalFindProxyForURL = FindProxyForURL; /******/ let tmp = function(url, host) { -/******/ const dotHost = '.' + host; +/******/ const dotHostDot = '.' + host + (host.endsWith('.') ? '' : '.'); ${ function() { let generatedPac = ` @@ -373,7 +373,7 @@ /******/ ${JSON.stringify(pacMods.whitelist)}.some((whiteHost) => { /******/ const ifWild = whiteHost.startsWith('*'); /******/ if (ifWild) { -/******/ return dotHost.endsWith(whiteHost.substr(1)); +/******/ return dotHostDot.endsWith(whiteHost.substr(1)); /******/ } /******/ 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 = {}; if (pacMods.ifProxyMoreDomains) { finalExceptions = pacMods.moreDomains.reduce((acc, tld) => { @@ -440,19 +437,19 @@ /******/ /******/ /* EXCEPTIONS START */ // TODO: handle wildcards. -/******/ const isHostInDomain = (domain, ifWild) => { +/******/ const isHostInDomain = (suffix, 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('*.'); -/******/ if (!isHostInDomain(domain, ifWild)) { + const ifWild = suffix.startsWith('*.'); +/******/ if (!isHostInDomain(suffix, ifWild)) { /******/ return maxWeight; /******/ } - let len = domain.length; + let len = suffix.length; if (ifWild) { len = len === 0 ? len : (len - 2)*2 - 1; } else { diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.mjs b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.mjs index d76d4f8..3748ad1 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.mjs +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.mjs @@ -586,7 +586,7 @@ 'handlers-pac-error', 'handlers-ext-error', 'handlers-no-control', - ]; + ]; /* Event handlers that ALWAYS work (even if installation is not done or failed). @@ -677,13 +677,29 @@ console.log('Updating from', oldAntiCensorRu.version, 'to', antiCensorRu.version); try { - if (window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.57')) { - const azWithPort = 'https://antizapret.prostovpn.org:8443/proxy.pac'; - const azWithPortAlt = 'https://antizapret.prostovpn.org:18443/proxy.pac'; - const urls = window.apis.antiCensorRu.pacProviders['Антизапрет'].pacUrls; - urls[0] = 'https://antizapret.prostovpn.org/proxy.pac'; - urls.unshift(azWithPort, azWithPortAlt); - console.log('Successfully updated to 0.0.1.58.'); + switch(true) { + case window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.57'): { + const azWithPort = 'https://antizapret.prostovpn.org:8443/proxy.pac'; + const azWithPortAlt = 'https://antizapret.prostovpn.org:18443/proxy.pac'; + const urls = window.apis.antiCensorRu.pacProviders['Антизапрет'].pacUrls; + urls[0] = 'https://antizapret.prostovpn.org/proxy.pac'; + urls.unshift(azWithPort, azWithPortAlt); + 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) { // Log update error. diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/exceptions/index.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/exceptions/index.js index fbfe545..e3cc0a2 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/exceptions/index.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/exceptions/index.js @@ -54,6 +54,7 @@ ${(mods.whitelist || []).join('\n')} .trim() .split(/(?:\s*\r?\n\s*)+/g) .filter((host) => host) + .map((host) => host.endsWith('.') ? host : `${host}.`) ) dontProxyList = dontProxyList || []; whitelist = whitelist || [];