mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2025-01-31 20:04:11 +03:00
Merge branch 'domains-end-with-a-dot' into to-esm-modules
This commit is contained in:
commit
bb14665ea3
|
@ -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 {
|
||||
|
|
|
@ -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')) {
|
||||
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.
|
||||
|
|
|
@ -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 || [];
|
||||
|
|
Loading…
Reference in New Issue
Block a user