Merge branch 'development' into production

This commit is contained in:
Ilya Ig. Petrov 2019-04-15 07:54:34 +00:00
commit e6d5be6e56
13 changed files with 2952 additions and 1240 deletions

View File

@ -21,7 +21,7 @@ I believe __information mustn't be blocked based on political or other subjectiv
My maxim is _"Your freedom ends when it starts to confine the freedom of others"_.
See [my other arguments against censorship (ru)](https://gist.github.com/ilyaigpetrov/9452b93ef3d7dd3d8cc2)
See [my other arguments against censorship (ru)](https://rebrand.ly/ac-arguments)
Looking at how Russian government [distorts TV](https://therussianreader.wordpress.com/2015/11/22/russian-truckers-strike-dagestan/) and blocks [critics of Putin](http://www.reuters.com/article/2014/03/13/us-russia-internet-idUSBREA2C21L20140313),
I decided to write an anticensorship extension for Chromium before they strike me first.
@ -37,7 +37,7 @@ I decided to write an anticensorship extension for Chromium before they strike m
## Contributors
This project exists thanks to all the people who contribute.
<a href="graphs/contributors"><img src="https://opencollective.com/anticensority/contributors.svg?width=890&button=false" /></a>
<a href="graphs/contributors"><img src="https://opencollective.com/anticensority/contributors.svg?width=890&button=false?force" /></a>
## Backers

View File

@ -1,8 +1,5 @@
# Install
Nodejs 10 and gulp have [issues](https://github.com/nodejs/node/issues/20285),
use nodejs 8 instead for a while.
```
npm install
cd src/extension-common/pages/options/
@ -14,10 +11,7 @@ use your build/extension-beta
# Release
1. `vim src/extension-common/pages/options/src/components/App.js`
2. Change github link there.
3. `npm run release`
4. Change `App.js` back to original: `git checkout src/extension-common/pages/options/src/components/App.js`
5. `vim src/templates-data.js` and bump version.
6. Commit bumped version.
7. Merge development to production (usually after deployment and testing and many patches).
1. `npm run release`
2. `vim src/templates-data.js` and bump version.
3. Commit bumped version.
4. Merge development to production (usually after deployment and testing and many patches).

View File

@ -18,8 +18,7 @@
Если расширение не работает: https://git.io/vgDDj
Антицензура на Реддите: https://www.reddit.com/r/anticensorship_russia
Группа в G+: https://goo.gl/Lh0Cjh
История изменений: https://github.com/ilyaigpetrov/anti-censorship-russia/releases
История изменений: https://github.com/anticensority/runet-censorship-bypass/releases
# Дополнительно

View File

@ -3,7 +3,7 @@
const gulp = require('gulp');
const del = require('del');
const through = require('through2');
const PluginError = require('gulp-util').PluginError;
const PluginError = require('plugin-error');
const changed = require('gulp-changed');
const PluginName = 'Template literals';
@ -29,7 +29,7 @@ const templatePlugin = (context) => through.obj(function(file, encoding, cb) {
}, { keys: [], values: [] });
try {
file.contents = new Buffer(
file.contents = Buffer.from(
(new Function(...keys, 'return `' + String(file.contents) + '`;'))(...values)
);
} catch(e) {
@ -43,14 +43,13 @@ const templatePlugin = (context) => through.obj(function(file, encoding, cb) {
});
gulp.task('default', ['build:beta']);
gulp.task('clean', function(cb) {
const clean = function(cb) {
//return del.sync('./build');
return cb();
});
};
const contexts = require('./src/templates-data').contexts;
@ -69,16 +68,16 @@ const firefoxSrc = './src/extension-firefox/**/*';
const joinSrc = (...args) => [...args, ...excluded];
gulp.task('_cp-mini', function(cb) {
const copyMini = function(cb) {
gulp.src(joinSrc(commonSrc, miniSrc))
//.pipe(changed(miniDst))
.pipe(templatePlugin(contexts.mini))
.pipe(gulp.dest(miniDst))
.on('end', cb);
});
};
gulp.task('_cp-full', function(cb) {
const copyFull = function(cb) {
gulp.src(joinSrc(commonSrc, fullSrc))
//.pipe(changed(fullDst))
@ -86,19 +85,9 @@ gulp.task('_cp-full', function(cb) {
.pipe(gulp.dest(fullDst))
.on('end', cb);
});
};
gulp.task('_cp-firefox', function(cb) {
gulp.src(joinSrc(commonSrc, fullSrc, firefoxSrc))
//.pipe(changed(fullDst))
.pipe(templatePlugin(contexts.firefox))
.pipe(gulp.dest(firefoxDst))
.on('end', cb);
});
gulp.task('_cp-beta', function(cb) {
const copyBeta = function(cb) {
gulp.src(joinSrc(commonSrc, fullSrc))
//.pipe(changed(fullDst))
@ -106,8 +95,13 @@ gulp.task('_cp-beta', function(cb) {
.pipe(gulp.dest(betaDst))
.on('end', cb);
});
};
gulp.task('build:all', ['_cp-mini', '_cp-full', '_cp-beta', '_cp-firefox']);
gulp.task('build:beta', ['_cp-beta']);
gulp.task('build:firefox', ['_cp-firefox']);
const buildAll = gulp.parallel(copyMini, copyFull, copyBeta);
const buildBeta = copyBeta;
module.exports = {
default: buildAll,
buildAll,
buildBeta,
};

File diff suppressed because it is too large Load Diff

View File

@ -8,8 +8,8 @@
"test": "mocha --recursive ./src/**/test/*",
"subpages": "cd ./src/extension-common/pages/options/ && npm run build && cd -",
"subpages:dev": "cd ./src/extension-common/pages/options/ && npm run build:dev:nocomp && cd -",
"start": "npm run subpages:dev && npm run gulp build:beta",
"release": "npm run subpages && npm run gulp build:all"
"start": "npm run subpages:dev && npm run gulp buildAll",
"release": "npm run subpages && npm run gulp buildAll"
},
"author": "Ilya Ig. Petrov",
"license": "GPLv3",
@ -23,8 +23,9 @@
"symlink-to": "^0.0.4"
},
"dependencies": {
"del": "^2.2.2",
"gulp": "^3.9.1",
"through2": "^2.0.3"
"del": "^3.0.0",
"gulp": "^4.0.0",
"plugin-error": "^1.0.1",
"through2": "^3.0.0"
}
}

View File

@ -19,6 +19,14 @@
*/
/*
Due to History
- *Async suffix usually means that function requires a cb.
It may not be related to async (returning a Promise).
This naming is confusing and should be reconsidered.
*/
{ // Private namespace starts.
const mandatory = window.utils.mandatory;
@ -50,7 +58,7 @@
};
const setPacAsync = function setPacAsync(
pacData = mandatory(), cb = throwIfError
pacData = mandatory(), cb = throwIfError,
) {
const config = {
@ -72,7 +80,7 @@
console.warn('Failed, other extension is in control.');
return cb(
new Error( window.utils.messages.whichExtensionHtml() )
new Error( window.utils.messages.whichExtensionHtml() ),
);
}
@ -91,20 +99,20 @@
cb = asyncLogGroup(
'Getting IPs for PAC hosts...',
cb
cb,
);
window.utils.fireRequest('ip-to-host-update-all', cb);
};
const setPacScriptFromProviderAsync = async function setPacScriptFromProviderAsync(
provider, lastModifiedStr = mandatory(), cb = throwIfError
const setPacScriptFromProviderAsync = function setPacScriptFromProviderAsync(
provider, lastModifiedStr = mandatory(), cb = throwIfError,
) {
const pacUrl = provider.pacUrls[0];
cb = asyncLogGroup(
'Getting PAC script from provider...', pacUrl,
cb
cb,
);
const warnings = [];
@ -119,9 +127,8 @@
addWarning(
\`
Не найдено СВОИХ прокси. Этот PAC-скрипт
<a href="https://github.com/anticensority/runet-censorship-bypass/issues/10#issuecomment-387436191">теперь</a>
работает только со <a href="https://git.io/ac-own-proxy">СВОИМИ прокси</a>
(по умолчанию используется локальный <a href="https://git.io/ac-tor">TOR</a> и прокси "Антизапрет", для их отключения: Свои прокси -> откл. "Использовать прокси PAC-скрипта").
(по умолчанию будет использоваться локальный <a href="https://git.io/ac-tor">Tor</a>).
\`,
);
}
@ -131,15 +138,14 @@
httpLib.ifModifiedSince(pacUrl, lastModifiedStr, (err, newLastModifiedStr) => {
if (!newLastModifiedStr) {
const res = {lastModified: lastModifiedStr};
const ifWasEverModified = lastModifiedStr !== new Date(0).toUTCString();
if (ifWasEverModified) {
addWarning(
'Ваш PAC-скрипт не нуждается в обновлении. Его дата: ' +
lastModifiedStr
lastModifiedStr,
);
const res = {lastModified: lastModifiedStr};
return cb(null, res);
}
}
@ -150,11 +156,11 @@
() => new Promise(
(resolve, reject) => httpLib.get(
url,
(newErr, pacData) => newErr ? reject(newErr) : resolve(pacData)
)
)
(newErr, pacData) => newErr ? reject(newErr) : resolve(pacData),
),
),
),
Promise.reject()
Promise.reject(),
);
pacDataPromise.then(
@ -166,7 +172,7 @@
(err, res) => cb(
err,
Object.assign(res || {}, {lastModified: newLastModifiedStr}),
)
),
);
},
@ -223,7 +229,7 @@
order: 99,
pacUrls: [
'data:application/x-ns-proxy-autoconfig,' + escape('function FindProxyForURL(){ return "DIRECT"; }'),
]
],
}
},
@ -239,6 +245,12 @@
Do something, e.g. initiate PAC sync.
*/
ifFirstInstall: false,
/* We have .lastPacUpdateStamp and ._currentPacProviderLastModified.
LastModified is received from a server, we kind of don't trust it,
just use it for cache and maybe show to the user.
UpdateStamp is got from client and we base our timers on it,
malicious server can't interfere with it.
*/
lastPacUpdateStamp: 0,
setTitle() {
@ -251,7 +263,7 @@
},
_currentPacProviderLastModified: 0, // Not initialized.
_currentPacProviderLastModified: 0,
getLastModifiedForKey(key = mandatory()) {
@ -284,7 +296,7 @@
setCurrentPacProviderKey(
newKey = mandatory(),
lastModified = new Date().toUTCString()
lastModified = new Date().toUTCString(),
) {
this.mustBeKey(newKey);
@ -324,7 +336,7 @@
chrome.storage.local.clear(
() => chrome.storage.local.set(
onlySettable,
chromified(cb)
chromified(cb),
)
);
@ -368,8 +380,8 @@
const ipsErrorPromise = new Promise(
(resolve, reject) => updatePacProxyIps(
resolve
)
resolve,
),
);
Promise.all([pacSetPromise, ipsErrorPromise]).then(
@ -383,7 +395,7 @@
warns.push(ipsErr);
}
this.pushToStorageAsync(
(pushErr) => cb(pacErr || pushErr, null, ...warns)
(pushErr) => cb(pacErr || pushErr, null, ...warns),
);
},
@ -410,7 +422,7 @@
console.log(
'Next PAC update is scheduled on',
new Date(nextUpdateMoment).toLocaleString('ru-RU')
new Date(nextUpdateMoment).toLocaleString('ru-RU'),
);
chrome.alarms.create(
@ -453,11 +465,11 @@
}
this.setCurrentPacProviderKey(null);
this.pushToStorageAsync(
() => handlers.updateControlState(cb)
() => handlers.updateControlState(cb),
);
})
)
}),
),
);
},
@ -485,7 +497,7 @@
if (alarm.name === antiCensorRu._periodicUpdateAlarmReason) {
console.log(
'Periodic PAC update triggered:',
new Date().toLocaleString('ru-RU')
new Date().toLocaleString('ru-RU'),
);
antiCensorRu.syncWithPacProviderAsync(() => {/* swallow */});
}
@ -525,7 +537,7 @@
|| antiCensorRu._currentPacProviderLastModified;
console.log(
'Last PAC update was on',
new Date(antiCensorRu.lastPacUpdateStamp).toLocaleString('ru-RU')
new Date(antiCensorRu.lastPacUpdateStamp).toLocaleString('ru-RU'),
);

View File

@ -8,7 +8,7 @@
"icons": {
"128": "/icons/default-128.png"
},
"author": "ilyaigpetrov@gmail.com",
"author": "anticensority+owners@googlegroups.com",
"permissions": [
"proxy"

View File

@ -1096,7 +1096,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.1.1",
@ -1147,7 +1148,8 @@
"balanced-match": {
"version": "0.4.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"bcrypt-pbkdf": {
"version": "1.0.1",
@ -1162,6 +1164,7 @@
"version": "0.0.9",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"inherits": "~2.0.0"
}
@ -1170,6 +1173,7 @@
"version": "2.10.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"hoek": "2.x.x"
}
@ -1178,6 +1182,7 @@
"version": "1.1.7",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^0.4.1",
"concat-map": "0.0.1"
@ -1186,7 +1191,8 @@
"buffer-shims": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"caseless": {
"version": "0.12.0",
@ -1203,12 +1209,14 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"combined-stream": {
"version": "1.0.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"delayed-stream": "~1.0.0"
}
@ -1216,22 +1224,26 @@
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"cryptiles": {
"version": "2.0.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"boom": "2.x.x"
}
@ -1271,7 +1283,8 @@
"delayed-stream": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"delegates": {
"version": "1.0.0",
@ -1303,7 +1316,8 @@
"extsprintf": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"forever-agent": {
"version": "0.6.1",
@ -1325,12 +1339,14 @@
"fs.realpath": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"fstream": {
"version": "1.0.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"graceful-fs": "^4.1.2",
"inherits": "~2.0.0",
@ -1386,6 +1402,7 @@
"version": "7.1.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -1398,7 +1415,8 @@
"graceful-fs": {
"version": "4.1.11",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"har-schema": {
"version": "1.0.5",
@ -1426,6 +1444,7 @@
"version": "3.1.3",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"boom": "2.x.x",
"cryptiles": "2.x.x",
@ -1436,7 +1455,8 @@
"hoek": {
"version": "2.16.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"http-signature": {
"version": "1.1.1",
@ -1453,6 +1473,7 @@
"version": "1.0.6",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
@ -1461,7 +1482,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.4",
@ -1473,6 +1495,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "1.0.1"
}
@ -1486,7 +1509,8 @@
"isarray": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"isstream": {
"version": "0.1.2",
@ -1559,12 +1583,14 @@
"mime-db": {
"version": "1.27.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"mime-types": {
"version": "2.1.15",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"mime-db": "1.27.0"
}
@ -1573,6 +1599,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "1.1.7"
}
@ -1580,12 +1607,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -1640,7 +1669,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"oauth-sign": {
"version": "0.8.2",
@ -1658,6 +1688,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -1687,7 +1718,8 @@
"path-is-absolute": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"performance-now": {
"version": "0.2.0",
@ -1698,7 +1730,8 @@
"process-nextick-args": {
"version": "1.0.7",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"punycode": {
"version": "1.4.1",
@ -1736,6 +1769,7 @@
"version": "2.2.9",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"buffer-shims": "~1.0.0",
"core-util-is": "~1.0.0",
@ -1780,6 +1814,7 @@
"version": "2.6.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"glob": "^7.0.5"
}
@ -1787,7 +1822,8 @@
"safe-buffer": {
"version": "5.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"semver": {
"version": "5.3.0",
@ -1811,6 +1847,7 @@
"version": "1.0.9",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"hoek": "2.x.x"
}
@ -1844,6 +1881,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -1854,6 +1892,7 @@
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.0.1"
}
@ -1868,6 +1907,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -1882,6 +1922,7 @@
"version": "2.2.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"block-stream": "*",
"fstream": "^1.0.2",
@ -1937,7 +1978,8 @@
"util-deprecate": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"uuid": {
"version": "3.0.1",
@ -1966,7 +2008,8 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},

View File

@ -69,31 +69,21 @@
const reinit = function reinit() {
// Defaults.
const _antizapret = {
/* Don't use directly, please.
Encoded to counter abuse. */
host: '\x70\x72\x6f\x78\x79\x2e\x61\x6e\x74\x69\x7a\x61\x70\x72\x65\x74\x2e\x70\x72\x6f\x73\x74\x6f\x76\x70\x6e\x2e\x6f\x72\x67',
};
const proxyForRanges =
'\x63\x63\x61\x68\x69\x68\x61\x2e\x61\x6e\x74\x69\x7a\x61\x70\x72\x65\x74\x2e\x70\x72\x6f\x73\x74\x6f\x76\x70\x6e\x2e\x6f\x72\x67';
privates._strToHostObj = {
[_antizapret.host]: _antizapret,
[proxyForRanges]: { host: proxyForRanges },
['localhost']: { host: 'localhost' },
};
/* Don't use directly, please.
Encoded to counter abuse.
*/
privates._strToHostObj = [
// antizapret.prostovpn.org:
'\x70\x72\x6f\x78\x79\x2e\x61\x6e\x74\x69\x7a\x61\x70\x72\x65\x74\x2e\x70\x72\x6f\x73\x74\x6f\x76\x70\x6e\x2e\x6f\x72\x67', // Antizapret old.
'\x63\x63\x61\x68\x69\x68\x61\x2e\x61\x6e\x74\x69\x7a\x61\x70\x72\x65\x74\x2e\x70\x72\x6f\x73\x74\x6f\x76\x70\x6e\x2e\x6f\x72\x67', // Antizapret for ranges.
'\x70\x72\x6f\x78\x79\x2d\x73\x73\x6c\x2e\x61\x6e\x74\x69\x7a\x61\x70\x72\x65\x74\x2e\x70\x72\x6f\x73\x74\x6f\x76\x70\x6e\x2e\x6f\x72\x67', // Antizapret SSL.
'\x70\x72\x6f\x78\x79\x2d\x6e\x6f\x73\x73\x6c\x2e\x61\x6e\x74\x69\x7a\x61\x70\x72\x65\x74\x2e\x70\x72\x6f\x73\x74\x6f\x76\x70\x6e\x2e\x6f\x72\x67', // Antizapret w/o SSL.
].reduce((acc, hostname) => ({...acc, [hostname]: { host: hostname }}), {
// Defaults:
localhost: { host: 'localhost' },
});
privates._ipToHostObj = {};
for( const ip of [
// IPs of Antizapret.
'195.123.209.38',
'137.74.171.91',
'51.15.39.201',
'2001:bc8:4700:2300::1:d07',
'2a02:27ac::10',
] ) {
privates._ipToHostObj[ip] = _antizapret;
}
// Persisted.
const ipToHost = _state(ip2host);

View File

@ -9,8 +9,6 @@
to "loading".
So if you set a title earlier it may be cleared by browser.
It pertains not only to page refesh but to newly opened pages too.
Also on loosing title see:
https://github.com/ilyaigpetrov/repository-for-chrome-bugs/blob/master/browserAction-title-lost-after-setting/background.js
Crazy parallel Chrome.
**/

View File

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

View File

@ -5,7 +5,7 @@
"scripts": {
"postinstall": "opencollective postinstall"
},
"author": "ilyaigpetrov",
"author": "anticensority+owners@googlegroups.com",
"license": "ISC",
"dependencies": {
"opencollective": "^1.0.3"