From b2cf7113099da9d9d2e3e828eeb21a6ac537ac1e Mon Sep 17 00:00:00 2001 From: ilyaigpetrov Date: Tue, 2 May 2023 21:10:47 +0500 Subject: [PATCH] FQDN that end with a dot in the configs (not finished) --- .../runet-censorship-bypass/README.md | 14 +-- .../extension-common/35-pac-kitchen-api.js | 29 +++-- ...c-pac-script-with-pac-provider-api.tmpl.js | 102 +++++------------- .../src/extension-common/70-menu-items.js | 4 +- .../src/extension-common/FOR-REVIEWERS.md | 46 ++++++++ .../src/extension-common/README.md | 1 - .../pages/exceptions/index.js | 1 + .../pages/troubleshoot/index.html | 12 +-- .../src/extension-full/20-ip-to-host-api.js | 1 + .../src/templates-data.js | 2 +- 10 files changed, 96 insertions(+), 116 deletions(-) create mode 100644 extensions/chromium/runet-censorship-bypass/src/extension-common/FOR-REVIEWERS.md delete mode 100644 extensions/chromium/runet-censorship-bypass/src/extension-common/README.md diff --git a/extensions/chromium/runet-censorship-bypass/README.md b/extensions/chromium/runet-censorship-bypass/README.md index f0eac61..c073363 100644 --- a/extensions/chromium/runet-censorship-bypass/README.md +++ b/extensions/chromium/runet-censorship-bypass/README.md @@ -23,19 +23,7 @@ npm start # For Reviewers -Steps to reproduce the same zip: -``` -npm ci -cd src/extension-common/pages/options/ -npm ci -cd - -npm start -# See ./build/extension-full -cd ./build/extension-full -zip -r runet-censorship-bypass-full.zip ./* -``` - -https://antizapret.prostovpn.org/proxy.pac is generated by https://bitbucket.org/anticensority/antizapret-pac-generator-light/, reviewers may find justifications related to this PAC-script in that repo. +See ./src/extension-common/FOR-REVIEWERS.md. # Release Instructions diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js index 47aa1fe..1dc304f 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js @@ -308,12 +308,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) { @@ -366,7 +366,7 @@ /******/ /******/ const originalFindProxyForURL = FindProxyForURL; /******/ let tmp = function(url, host) { -/******/ const dotHost = '.' + host; +/******/ const dotHostDot = '.' + host + (host.endsWith('.') ? '' : '.'); ${ function() { let generatedPac = ` @@ -375,7 +375,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; /******/ }) @@ -420,9 +420,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) => { @@ -442,19 +439,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.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js index cf604bc..9b70b06 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js @@ -138,7 +138,6 @@ if (err) { if (err.message === 'proxy.settings requires private browsing permission.') { - // window.utils.openAndFocus('https://rebrand.ly/ac-allow-private-windows'); clarifyThen( chrome.i18n.getMessage('AllowExtensionToRunInPrivateWindows'), cb, @@ -230,7 +229,7 @@ ); return (ifUnattended ? tryPromiseSeveralTimesAsync(tryAllUrlsAsync, [20, 40, 60]) - : tryAllUrlsAsync() + : tryAllUrlsAsync() ).catch( (err) => Promise.reject(clarify( err, @@ -276,6 +275,8 @@ \`, order: 0, pacUrls: [ + 'https://antizapret.prostovpn.org:8443/proxy.pac', + 'https://antizapret.prostovpn.org:18443/proxy.pac', 'https://antizapret.prostovpn.org/proxy.pac', 'https://rebrand.ly/ac-antizapret-pac', ], @@ -588,34 +589,6 @@ 'handlers-ext-error', 'handlers-no-control', ]; - - if (!Object.keys(oldAntiCensorRu).length) { - const storage = await window.utils.promisedLocalStorage.get(null); - if (storage.version && window.apis.version.isLeq(storage.version, '0.0.1.48')) { - const ffxPacData = storage['firefox-only-pac-data']; - delete storage['firefox-only-pac-data']; - await window.utils.promisedLocalStorage.clear(); - for(const key of otherKeys) { - await window.utils.promisedLocalStorage.set({ [key]: storage[key] }); - delete storage[key]; - } - await window.utils.promisedLocalStorage.set({ antiCensorRu: storage }); - oldAntiCensorRu = storage; - } - } - if (oldAntiCensorRu.version && window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.49')) { - const modsMutated = window.apis.pacKitchen.getPacModsRaw(); - if (modsMutated && modsMutated.exceptions) { - modsMutated.exceptions = Object.entries(modsMutated.exceptions).reduce((acc, [host, ifProxy]) => { - acc[\`*.\${host}\`] = ifProxy; - return acc; - }, {}); - await new Promise( - (resolve) => window.apis.pacKitchen.keepCookedNowAsync(modsMutated, resolve), - ); - } - } - /* Event handlers that ALWAYS work (even if installation is not done or failed). @@ -706,54 +679,29 @@ console.log('Updating from', oldAntiCensorRu.version, 'to', antiCensorRu.version); try { - if (window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.5')) { - - // Change semicolons to semicolons followed by newlines in proxy string (raw). - const migrateProxies = (oldStr) => oldStr.replace(/;\\r?\\n?/g, ';\\n'); - const modsMutated = window.apis.pacKitchen.getPacModsRaw(); - if (modsMutated) { - modsMutated['customProxyStringRaw'] = migrateProxies(modsMutated['customProxyStringRaw']); - await new Promise( - (resolve) => window.apis.pacKitchen.keepCookedNowAsync(modsMutated, resolve), + 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()), ); - } - - } - if (window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.25')) { - - console.log('Switch to Antizapret automatically, only from Anitcensority without own proxies.'); - const provKey = antiCensorRu.getCurrentPacProviderKey(); - if (provKey !== 'Антицензорити' && provKey !== 'Антизапрет') { - console.log('Current provider', provKey, '!== Anticensority or Antizapret'); - return; // Not Anticensority. - } - const pacMods = window.apis.pacKitchen.getPacMods(); - if (pacMods.filteredCustomsString) { - console.log('Proxies found:', pacMods.filteredCustomsString); - return; // Own proxies or Tor are used. - } - antiCensorRu.setCurrentPacProviderKey('Антизапрет'); - antiCensorRu.setLastModified(0); - await new Promise((resolveSwitch) => - - antiCensorRu.syncWithPacProviderAsync((err, res, warns) => { - - if (warns) { - console.log(warns); - } - if (err) { - console.log( - 'Ungraceful update from 1.25: couldn\\'t fetch Antizapret:', - ); - console.error(err); - } else { - console.log('Update from 1.25 applied successfully.'); - } - resolveSwitch(); - - }), - ); - + 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/70-menu-items.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/70-menu-items.js index 6eed9b3..2a91768 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/70-menu-items.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/70-menu-items.js @@ -27,7 +27,7 @@ otherUnblock: { title: 'Разблокировать по-другому', - getUrl: (blockedUrl) => ('https://rebrand.ly/ac-unblock#' + blockedUrl), + getUrl: (blockedUrl) => ('https://anticensority.github.io/unblock#' + blockedUrl), order: 3, }, @@ -39,7 +39,7 @@ support: { title: 'Документация / Помощь / Поддержка', - getUrl: (blockedUrl) => 'https://git.io/ac-wiki', + getUrl: (blockedUrl) => 'https://github.com/anticensority/runet-censorship-bypass/wiki', order: 99, }, diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/FOR-REVIEWERS.md b/extensions/chromium/runet-censorship-bypass/src/extension-common/FOR-REVIEWERS.md new file mode 100644 index 0000000..1e5943e --- /dev/null +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/FOR-REVIEWERS.md @@ -0,0 +1,46 @@ +# For Reviewers + +## Prerequirements + +You need a globally installed `gulp-cli@2.3.0`. +See https://gulpjs.com/docs/en/getting-started/quick-start#install-the-gulp-command-line-utility. + +## Steps + +Steps to reproduce the same zip: +``` +npm ci +cd src/extension-common/pages/options/ +npm ci +cd - +npm start +# See ./build/extension-full +cd ./build/extension-full +zip -r runet-censorship-bypass-full.zip ./* +``` + +## Minified Files + +### Ace Editor + +https://ace.c9.io -> https://github.com/ajaxorg/ace -> Building Ace -> "The ace-builds repository endeavours to maintain the latest build" -> https://github.com/ajaxorg/ace-builds/ -> Select tag of 1.2.5, open https://github.com/ajaxorg/ace-builds/tree/v1.2.5/src-min and download the files you want to check. + + +``` +mkdir downloaded +cd downloaded +wget https://raw.githubusercontent.com/ajaxorg/ace-builds/v1.2.5/src-min/ace.js +wget https://raw.githubusercontent.com/ajaxorg/ace-builds/v1.2.5/src-min/ext-searchbox.js +wget https://raw.githubusercontent.com/ajaxorg/ace-builds/v1.2.5/src-min/mode-javascript.js +wget https://raw.githubusercontent.com/ajaxorg/ace-builds/v1.2.5/src-min/worker-javascript.js + +downloaded$ for i in ./*; do md5sum "$i"; done +2b9a1157bb3ba711a0402b6751d9ac71 ./ace.js +1f73efaff2853571af0e701c5e9a15ee ./ext-searchbox.js +e5eebd85c4e66667c28f124e6a07e3ed ./mode-javascript.js +f0d1342102d16ab7abe319b2683d10ea ./worker-javascript.js +``` + +## PAC-Script AntiZapret + +https://antizapret.prostovpn.org/proxy.pac is generated by https://bitbucket.org/anticensority/antizapret-pac-generator-light/, reviewers may find justifications related to this PAC-script in that repo. \ No newline at end of file diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/README.md b/extensions/chromium/runet-censorship-bypass/src/extension-common/README.md deleted file mode 100644 index 03f3faf..0000000 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/README.md +++ /dev/null @@ -1 +0,0 @@ -Files of this directory must be copied into final build without modifications. \ No newline at end of file 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 || []; diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/troubleshoot/index.html b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/troubleshoot/index.html index 23eada7..1c8be1d 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/troubleshoot/index.html +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/troubleshoot/index.html @@ -10,12 +10,12 @@
  1. Детали последних ошибок
  2. Сбросить настройки
  3. -
  4. Файл самопомощи
  5. -
  6. Напишите нам!
  7. +
  8. Файл самопомощи
  9. +
  10. Напишите нам!

Для продвинутых

    -
  1. Как прочитать логи?
  2. +
  3. Как прочитать логи?
  4. Отладка PAC-скрипта

@@ -23,12 +23,12 @@
  1. Details of last errors
  2. Reset settings
  3. -
  4. Troubleshoot guide (ru)
  5. -
  6. Write to us!
  7. +
  8. Troubleshoot guide (ru)
  9. +
  10. Write to us!

Advanced

    -
  1. How to read logs?
  2. +
  3. How to read logs?
  4. PAC-script debugging
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-full/20-ip-to-host-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-full/20-ip-to-host-api.js index 5907709..a13c52f 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-full/20-ip-to-host-api.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-full/20-ip-to-host-api.js @@ -75,6 +75,7 @@ 'proxy.antizapret.prostovpn.org', 'proxy-ssl.antizapret.prostovpn.org', 'proxy-nossl.antizapret.prostovpn.org', + 'proxy-fbtw-ssl.antizapret.prostovpn.org', ].reduce((acc, hostname) => Object.assign(acc, { [hostname]: { host: hostname }}), { // Defaults: localhost: { host: 'localhost' }, diff --git a/extensions/chromium/runet-censorship-bypass/src/templates-data.js b/extensions/chromium/runet-censorship-bypass/src/templates-data.js index e45071c..c98163e 100644 --- a/extensions/chromium/runet-censorship-bypass/src/templates-data.js +++ b/extensions/chromium/runet-censorship-bypass/src/templates-data.js @@ -10,7 +10,7 @@ const pacUrls = [ ]; const commonContext = { - version: '1.57', + version: '1.59', anticensorityPacUrls: [ ...pacUrls, ],