FQDN that end with a dot in the configs (not finished)

This commit is contained in:
ilyaigpetrov 2023-05-02 21:10:47 +05:00
parent 6858c56534
commit b2cf711309
10 changed files with 96 additions and 116 deletions

View File

@ -23,19 +23,7 @@ npm start
# For Reviewers # For Reviewers
Steps to reproduce the same zip: See ./src/extension-common/FOR-REVIEWERS.md.
```
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.
# Release Instructions # Release Instructions

View File

@ -308,12 +308,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) {
@ -366,7 +366,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 = `
@ -375,7 +375,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;
/******/ }) /******/ })
@ -420,9 +420,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) => {
@ -442,19 +439,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

@ -138,7 +138,6 @@
if (err) { if (err) {
if (err.message === 'proxy.settings requires private browsing permission.') { if (err.message === 'proxy.settings requires private browsing permission.') {
// window.utils.openAndFocus('https://rebrand.ly/ac-allow-private-windows');
clarifyThen( clarifyThen(
chrome.i18n.getMessage('AllowExtensionToRunInPrivateWindows'), chrome.i18n.getMessage('AllowExtensionToRunInPrivateWindows'),
cb, cb,
@ -230,7 +229,7 @@
); );
return (ifUnattended return (ifUnattended
? tryPromiseSeveralTimesAsync(tryAllUrlsAsync, [20, 40, 60]) ? tryPromiseSeveralTimesAsync(tryAllUrlsAsync, [20, 40, 60])
: tryAllUrlsAsync() : tryAllUrlsAsync()
).catch( ).catch(
(err) => Promise.reject(clarify( (err) => Promise.reject(clarify(
err, err,
@ -276,6 +275,8 @@
\`, \`,
order: 0, order: 0,
pacUrls: [ pacUrls: [
'https://antizapret.prostovpn.org:8443/proxy.pac',
'https://antizapret.prostovpn.org:18443/proxy.pac',
'https://antizapret.prostovpn.org/proxy.pac', 'https://antizapret.prostovpn.org/proxy.pac',
'https://rebrand.ly/ac-antizapret-pac', 'https://rebrand.ly/ac-antizapret-pac',
], ],
@ -588,34 +589,6 @@
'handlers-ext-error', 'handlers-ext-error',
'handlers-no-control', '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 Event handlers that ALWAYS work (even if installation is not done
or failed). or failed).
@ -706,54 +679,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.5')) { switch(true) {
case window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.57'): {
// Change semicolons to semicolons followed by newlines in proxy string (raw). const azWithPort = 'https://antizapret.prostovpn.org:8443/proxy.pac';
const migrateProxies = (oldStr) => oldStr.replace(/;\\r?\\n?/g, ';\\n'); const azWithPortAlt = 'https://antizapret.prostovpn.org:18443/proxy.pac';
const modsMutated = window.apis.pacKitchen.getPacModsRaw(); const urls = window.apis.antiCensorRu.pacProviders['Антизапрет'].pacUrls;
if (modsMutated) { urls[0] = 'https://antizapret.prostovpn.org/proxy.pac';
modsMutated['customProxyStringRaw'] = migrateProxies(modsMutated['customProxyStringRaw']); urls.unshift(azWithPort, azWithPortAlt);
await new Promise( console.log('Successfully updated to 0.0.1.58.');
(resolve) => window.apis.pacKitchen.keepCookedNowAsync(modsMutated, resolve), }; // 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.
}
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();
}),
);
} }
} catch (e) { } catch (e) {
// Log update error. // Log update error.

View File

@ -27,7 +27,7 @@
otherUnblock: { otherUnblock: {
title: 'Разблокировать по-другому', title: 'Разблокировать по-другому',
getUrl: (blockedUrl) => ('https://rebrand.ly/ac-unblock#' + blockedUrl), getUrl: (blockedUrl) => ('https://anticensority.github.io/unblock#' + blockedUrl),
order: 3, order: 3,
}, },
@ -39,7 +39,7 @@
support: { support: {
title: 'Документация / Помощь / Поддержка', title: 'Документация / Помощь / Поддержка',
getUrl: (blockedUrl) => 'https://git.io/ac-wiki', getUrl: (blockedUrl) => 'https://github.com/anticensority/runet-censorship-bypass/wiki',
order: 99, order: 99,
}, },

View File

@ -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.

View File

@ -1 +0,0 @@
Files of this directory must be copied into final build without modifications.

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 || [];

View File

@ -10,12 +10,12 @@
<ol> <ol>
<li><a data-in-bg="false" href class="view-errors">Детали последних ошибок</a></li> <li><a data-in-bg="false" href class="view-errors">Детали последних ошибок</a></li>
<li><a data-in-bg="false" href class="reset-settings">Сбросить настройки</a></li> <li><a data-in-bg="false" href class="reset-settings">Сбросить настройки</a></li>
<li><a data-in-bg="false" href="https://rebrand.ly/ac-support" target="_blank">Файл самопомощи</a></li> <li><a data-in-bg="false" href="https://github.com/anticensority/runet-censorship-bypass/wiki/Если-расширение-не-работает" target="_blank">Файл самопомощи</a></li>
<li><a data-in-bg="false" href="https://rebrand.ly/ac-contact">Напишите нам!</a></li> <li><a data-in-bg="false" href="https://groups.google.com/g/anticensority">Напишите нам!</a></li>
</ol> </ol>
<h2>Для продвинутых</h2> <h2>Для продвинутых</h2>
<ol> <ol>
<li><a data-in-bg="false" href="https://rebrand.ly/ac-logs">Как прочитать логи?</a></li> <li><a data-in-bg="false" href="https://github.com/anticensority/runet-censorship-bypass/wiki/Как-прочитать-логи%3F-%28для-продвинутых%29">Как прочитать логи?</a></li>
<li><a data-in-bg="false" href="../debug/index.html">Отладка PAC-скрипта</a></li> <li><a data-in-bg="false" href="../debug/index.html">Отладка PAC-скрипта</a></li>
</ol> </ol>
<hr/> <hr/>
@ -23,12 +23,12 @@
<ol> <ol>
<li><a data-in-bg="false" href class="view-errors">Details of last errors</a></li> <li><a data-in-bg="false" href class="view-errors">Details of last errors</a></li>
<li><a data-in-bg="false" href class="reset-settings">Reset settings</a></li> <li><a data-in-bg="false" href class="reset-settings">Reset settings</a></li>
<li><a data-in-bg="false" href="https://rebrand.ly/ac-support" target="_blank">Troubleshoot guide (ru)</a></li> <li><a data-in-bg="false" href="https://github.com/anticensority/runet-censorship-bypass/wiki/Если-расширение-не-работает" target="_blank">Troubleshoot guide (ru)</a></li>
<li><a data-in-bg="false" href="https://rebrand.ly/ac-contact">Write to us!</a></li> <li><a data-in-bg="false" href="https://groups.google.com/g/anticensority">Write to us!</a></li>
</ol> </ol>
<h2>Advanced</h2> <h2>Advanced</h2>
<ol> <ol>
<li><a data-in-bg="false" href="https://rebrand.ly/ac-logs">How to read logs?</a></li> <li><a data-in-bg="false" href="https://github.com/anticensority/runet-censorship-bypass/wiki/Как-прочитать-логи%3F-%28для-продвинутых%29">How to read logs?</a></li>
<li><a data-in-bg="false" href="../debug/index.html">PAC-script debugging</a></li> <li><a data-in-bg="false" href="../debug/index.html">PAC-script debugging</a></li>
</ol> </ol>
<script src="./index.js"></script> <script src="./index.js"></script>

View File

@ -75,6 +75,7 @@
'proxy.antizapret.prostovpn.org', 'proxy.antizapret.prostovpn.org',
'proxy-ssl.antizapret.prostovpn.org', 'proxy-ssl.antizapret.prostovpn.org',
'proxy-nossl.antizapret.prostovpn.org', 'proxy-nossl.antizapret.prostovpn.org',
'proxy-fbtw-ssl.antizapret.prostovpn.org',
].reduce((acc, hostname) => Object.assign(acc, { [hostname]: { host: hostname }}), { ].reduce((acc, hostname) => Object.assign(acc, { [hostname]: { host: hostname }}), {
// Defaults: // Defaults:
localhost: { host: 'localhost' }, localhost: { host: 'localhost' },

View File

@ -10,7 +10,7 @@ const pacUrls = [
]; ];
const commonContext = { const commonContext = {
version: '1.57', version: '1.59',
anticensorityPacUrls: [ anticensorityPacUrls: [
...pacUrls, ...pacUrls,
], ],