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

View File

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

View File

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

View File

@ -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,
},

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()
.split(/(?:\s*\r?\n\s*)+/g)
.filter((host) => host)
.map((host) => host.endsWith('.') ? host : `${host}.`)
)
dontProxyList = dontProxyList || [];
whitelist = whitelist || [];

View File

@ -10,12 +10,12 @@
<ol>
<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="https://rebrand.ly/ac-support" 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://github.com/anticensority/runet-censorship-bypass/wiki/Если-расширение-не-работает" target="_blank">Файл самопомощи</a></li>
<li><a data-in-bg="false" href="https://groups.google.com/g/anticensority">Напишите нам!</a></li>
</ol>
<h2>Для продвинутых</h2>
<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>
</ol>
<hr/>
@ -23,12 +23,12 @@
<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="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://rebrand.ly/ac-contact">Write to us!</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://groups.google.com/g/anticensority">Write to us!</a></li>
</ol>
<h2>Advanced</h2>
<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>
</ol>
<script src="./index.js"></script>

View File

@ -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' },

View File

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