diff --git a/extensions/chromium/runet-censorship-bypass/.gitignore b/extensions/chromium/runet-censorship-bypass/.gitignore
index b4cc6d0..26f3785 100644
--- a/extensions/chromium/runet-censorship-bypass/.gitignore
+++ b/extensions/chromium/runet-censorship-bypass/.gitignore
@@ -2,5 +2,5 @@ node_modules
node_modules_linux
node_modules_win
npm-debug.log
-.swp
+*.swp
build/
diff --git a/extensions/chromium/runet-censorship-bypass/gulpfile.js b/extensions/chromium/runet-censorship-bypass/gulpfile.js
index 67faeb2..0f2ea15 100644
--- a/extensions/chromium/runet-censorship-bypass/gulpfile.js
+++ b/extensions/chromium/runet-censorship-bypass/gulpfile.js
@@ -4,6 +4,7 @@ const gulp = require('gulp');
const del = require('del');
const through = require('through2');
const PluginError = require('gulp-util').PluginError;
+const changed = require('gulp-changed');
const PluginName = 'Template literals';
@@ -44,9 +45,10 @@ const templatePlugin = (context) => through.obj(function(file, encoding, cb) {
gulp.task('default', ['build']);
-gulp.task('clean', function() {
+gulp.task('clean', function(cb) {
- return del.sync('./build');
+ //return del.sync('./build');
+ return cb();
});
@@ -56,31 +58,48 @@ const excFolder = (name) => [`!./src/**/${name}`, `!./src/**/${name}/**/*`];
const excluded = [ ...excFolder('test') , ...excFolder('node_modules'), ...excFolder('src') ];
const commonWoTests = ['./src/extension-common/**/*', ...excluded];
-gulp.task('_cp-common', ['clean'], function() {
+const miniDst = './build/extension-mini';
+const fullDst = './build/extension-full';
+
+gulp.task('_cp-common', ['clean'], function(cb) {
+
+ let fins = 0;
+ const intheend = () => {
+ if (++fins === 2) {
+ cb();
+ }
+ };
gulp.src(commonWoTests)
+ .pipe(changed(miniDst))
.pipe(templatePlugin(contexts.mini))
- .pipe(gulp.dest('./build/extension-mini'))
+ .pipe(gulp.dest(miniDst))
+ .on('end', intheend);
gulp.src(commonWoTests)
+ .pipe(changed(fullDst))
.pipe(templatePlugin(contexts.full))
- .pipe(gulp.dest('./build/extension-full'));
+ .pipe(gulp.dest(fullDst))
+ .on('end', intheend);
});
-gulp.task('_cp-mini', ['_cp-common'], function() {
+gulp.task('_cp-mini', ['_cp-common'], function(cb) {
gulp.src(['./src/extension-mini/**/*', ...excluded])
+ .pipe(changed(miniDst))
.pipe(templatePlugin(contexts.mini))
- .pipe(gulp.dest('./build/extension-mini'));
-
+ .pipe(gulp.dest(miniDst))
+ .on('end', cb);
});
-gulp.task('_cp-full', ['_cp-common'], function() {
+gulp.task('_cp-full', ['_cp-common'], function(cb) {
gulp.src(['./src/extension-full/**/*', ...excluded])
+ .pipe(changed(fullDst))
.pipe(templatePlugin(contexts.full))
- .pipe(gulp.dest('./build/extension-full'));
+ .pipe(gulp.dest(fullDst))
+ .on('end', cb);
});
diff --git a/extensions/chromium/runet-censorship-bypass/package.json b/extensions/chromium/runet-censorship-bypass/package.json
index 3b69739..531cee1 100644
--- a/extensions/chromium/runet-censorship-bypass/package.json
+++ b/extensions/chromium/runet-censorship-bypass/package.json
@@ -14,6 +14,7 @@
"chai": "^3.5.0",
"eslint": "^3.15.0",
"eslint-config-google": "^0.7.1",
+ "gulp-changed": "^3.1.0",
"mocha": "^3.3.0",
"sinon-chrome": "^2.2.1"
},
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 214d16a..f77aa9f 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
@@ -12,8 +12,7 @@
const ifIncontinence = 'if-incontinence';
const modsKey = 'mods';
- // Don't keep objects in defaults or at least freeze them!
- const configs = {
+ const getDefaultConfigs = () => ({// Configs user may mutate them and we don't care!
ifProxyHttpsUrlsOnly: {
dflt: false,
@@ -75,9 +74,9 @@
ifProxyMoreDomains: {
ifDisabled: true,
dflt: false,
- category: 'ownProxies',
+ category: 'exceptions',
label: 'проксировать .onion, .i2p и OpenNIC',
- desc: 'Проксировать особые домены. Необходима поддержка со стороны прокси.',
+ desc: 'Проксировать особые домены. Необходима поддержка со стороны СВОИХ прокси.',
order: 8,
},
ifProxyErrors: {
@@ -89,10 +88,11 @@
order: 9,
},
- };
+ });
const getDefaults = function getDefaults() {
+ const configs = getDefaultConfigs();
return Object.keys(configs).reduce((acc, key) => {
acc[key] = configs[key].dflt;
@@ -105,13 +105,14 @@
const getCurrentConfigs = function getCurrentConfigs() {
const oldMods = kitchenState(modsKey);
- if (oldMods) {
+ /*if (oldMods) {
// No migration!
return oldMods;
- }
+ }*/
- // In case of first install.
- const [err, mods, ...warns] = createPacModifiers();
+ // Client may expect mods.included and mods.excluded!
+ // On first install they are not defined.
+ const [err, mods, ...warns] = createPacModifiers(oldMods);
if (err) {
throw err;
}
@@ -122,6 +123,7 @@
const getOrderedConfigsForUser = function getOrderedConfigs(category) {
const pacMods = getCurrentConfigs();
+ const configs = getDefaultConfigs();
return Object.keys(configs)
.sort((keyA, keyB) => configs[keyA].order - configs[keyB].order)
.reduce((arr, key) => {
@@ -143,6 +145,7 @@
const createPacModifiers = function createPacModifiers(mods = {}) {
mods = mods || {}; // null?
+ const configs = getDefaultConfigs();
const ifNoMods = Object.keys(configs)
.every((dProp) => {
@@ -171,7 +174,8 @@
}
}
if (self.ifUseLocalTor) {
- customProxyArray.push('SOCKS5 localhost:9050', 'SOCKS5 localhost:9150');
+ self.torPoints = ['SOCKS5 localhost:9150', 'SOCKS5 localhost:9050'];
+ customProxyArray.push(...self.torPoints);
}
self.filteredCustomsString = '';
@@ -185,7 +189,18 @@
self.customProxyArray = false;
}
- self.included = self.excluded = undefined;
+ [self.included, self.excluded] = [[], []];
+ if (self.ifProxyMoreDomains) {
+ self.moreDomains = [
+ /* Networks */
+ 'onion', 'i2p',
+ /* OpenNIC */
+ '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'
+ ];
+ }
if (self.ifMindExceptions && self.exceptions) {
self.included = [];
self.excluded = [];
@@ -222,105 +237,140 @@
cook(pacData, pacMods = mandatory()) {
return pacMods.ifNoMods ? pacData : pacData + `${ kitchenStartsMark }
-;+function(global) {
- "use strict";
-
- const originalFindProxyForURL = FindProxyForURL;
- global.FindProxyForURL = function(url, host) {
- ${function() {
-
- let res = pacMods.ifProhibitDns ? `
- global.dnsResolve = function(host) { return null; };
- ` : '';
- if (pacMods.ifProxyHttpsUrlsOnly) {
-
- res += `
- if (!url.startsWith("https")) {
- return "DIRECT";
- }
- `;
- }
- res += `
- const directIfAllowed = ${pacMods.ifProxyOrDie ? '""/* Not allowed. */' : '"; DIRECT"'};`;
- if (pacMods.filteredCustomsString) {
- res += `
- const filteredCustomProxies = "; ${pacMods.filteredCustomsString}";`;
- }
-
- const ifIncluded = pacMods.included && pacMods.included.length;
- const ifExcluded = pacMods.excluded && pacMods.excluded.length;
- const ifExceptions = ifIncluded || ifExcluded;
-
- if (ifExceptions) {
- res += `
-
- /* EXCEPTIONS START */
- const dotHost = '.' + host;
- const isHostInDomain = (domain) => dotHost.endsWith('.' + domain);
- const domainReducer = (maxWeight, [domain, ifIncluded]) => {
-
- if (!isHostInDomain(domain)) {
- return maxWeight;
- }
- const newWeightAbs = domain.length;
- if (newWeightAbs < Math.abs(maxWeight)) {
- return maxWeight;
- }
- return newWeightAbs*(ifIncluded ? 1 : -1);
-
- };
-
- const excWeight = ${JSON.stringify(Object.entries(pacMods.exceptions))}.reduce( domainReducer, 0 );
- if (excWeight !== 0) {
- if (excWeight < 0) {
- // Never proxy it!
- return "DIRECT";
- }
- // Always proxy it!
- ${ pacMods.filteredCustomsString
- ? `return filteredCustomProxies + directIfAllowed;`
- : '/* No custom proxies -- continue. */'
- }
- }
- /* EXCEPTIONS END */
-`;
- }
- res += `
- const pacScriptProxies = originalFindProxyForURL(url, host)${
- pacMods.ifProxyOrDie ? '.replace(/DIRECT/g, "")' : ' + directIfAllowed'
- };`;
- if(
- !pacMods.ifUseSecureProxiesOnly &&
- !pacMods.filteredCustomsString &&
- pacMods.ifUsePacScriptProxies
- ) {
- return res + `
- return pacScriptProxies + directIfAllowed;`;
- }
-
- return res + `
- let pacProxyArray = pacScriptProxies.split(/(?:\\s*;\\s*)+/g).filter( (p) => p );
- const ifNoProxies = pacProxyArray${pacMods.ifProxyOrDie ? '.length === 0' : '.every( (p) => /^DIRECT$/i.test(p) )'};
- if (ifNoProxies) {
- // Directs only or null, no proxies.
- return "DIRECT";
- }
- return ` +
+/******/
+/******/;+function(global) {
+/******/ "use strict";
+/******/
+/******/ const originalFindProxyForURL = FindProxyForURL;
+/******/ global.FindProxyForURL = function(url, host) {
+/******/
+ ${
function() {
- if (!pacMods.ifUsePacScriptProxies) {
- return '';
- }
- let filteredPacExp = 'pacScriptProxies';
- if (pacMods.ifUseSecureProxiesOnly) {
- filteredPacExp =
- 'pacProxyArray.filter( (pStr) => /^HTTPS\\s/.test(pStr) ).join("; ")';
- }
- return filteredPacExp + ' + ';
+ let res = pacMods.ifProhibitDns ? `
+/******/
+/******/ global.dnsResolve = function(host) { return null; };
+/******/
+/******/` : '';
+ if (pacMods.ifProxyHttpsUrlsOnly) {
- }() + `${pacMods.filteredCustomsString ? 'filteredCustomProxies + ' : ''}directIfAllowed;`; // Without DIRECT you will get 'PROXY CONN FAILED' pac-error.
+ res += `
+/******/
+/******/ if (!url.startsWith("https")) {
+/******/ return "DIRECT";
+/******/ }
+/******/
+/******/ `;
+ }
+ if (pacMods.ifUseLocalTor) {
- }()}
+ res += `
+/******/
+/******/ if (host.endsWith(".onion")) {
+/******/ return "${pacMods.torPoints.join('; ')}";
+/******/ }
+/******/
+/******/ `;
+ }
+ res += `
+/******/
+/******/ const directIfAllowed = ${pacMods.ifProxyOrDie ? '""/* Not allowed. */' : '"; DIRECT"'};
+/******/`;
+ if (pacMods.filteredCustomsString) {
+ res += `
+/******/
+/******/ const filteredCustomProxies = "; ${pacMods.filteredCustomsString}";
+/******/`;
+ }
+
+ const ifIncluded = pacMods.included && pacMods.included.length;
+ const ifExcluded = pacMods.excluded && pacMods.excluded.length;
+ const ifManualExceptions = ifIncluded || ifExcluded;
+ const finalExceptions = {};
+ if (pacMods.ifProxyMoreDomains) {
+ pacMods.moreDomains.reduce((acc, tld) => {
+
+ acc[tld] = true;
+ return acc;
+
+ }, finalExceptions);
+ }
+ if (pacMods.ifMindExceptions || ifManualExceptions) {
+ Object.assign(finalExceptions, (pacMods.exceptions || {}));
+ }
+ const ifExceptions = Object.keys(finalExceptions).length;
+
+ if (ifExceptions) {
+ res += `
+/******/
+/******/ /* EXCEPTIONS START */
+/******/ const dotHost = '.' + host;
+/******/ const isHostInDomain = (domain) => dotHost.endsWith('.' + domain);
+/******/ const domainReducer = (maxWeight, [domain, ifIncluded]) => {
+/******/
+/******/ if (!isHostInDomain(domain)) {
+/******/ return maxWeight;
+/******/ }
+/******/ const newWeightAbs = domain.length;
+/******/ if (newWeightAbs < Math.abs(maxWeight)) {
+/******/ return maxWeight;
+/******/ }
+/******/ return newWeightAbs*(ifIncluded ? 1 : -1);
+/******/
+/******/ };
+/******/
+/******/ const excWeight = ${ JSON.stringify(Object.entries(finalExceptions)) }.reduce( domainReducer, 0 );
+/******/ if (excWeight !== 0) {
+/******/ if (excWeight < 0) {
+/******/ // Never proxy it!
+/******/ return "DIRECT";
+/******/ }
+/******/ // Always proxy it!
+${ pacMods.filteredCustomsString
+ ? `/******/ return filteredCustomProxies + directIfAllowed;`
+ : '/******/ /* No custom proxies -- continue. */'
+}
+/******/ }
+/******/ /* EXCEPTIONS END */
+`;
+ }
+ res += `
+/******/ const pacScriptProxies = originalFindProxyForURL(url, host)${
+/******/ pacMods.ifProxyOrDie ? '.replace(/DIRECT/g, "")' : ' + directIfAllowed'
+ };`;
+ if(
+ !pacMods.ifUseSecureProxiesOnly &&
+ !pacMods.filteredCustomsString &&
+ pacMods.ifUsePacScriptProxies
+ ) {
+ return res + `
+/******/ return pacScriptProxies + directIfAllowed;`;
+ }
+
+ return res + `
+/******/ let pacProxyArray = pacScriptProxies.split(/(?:\\s*;\\s*)+/g).filter( (p) => p );
+/******/ const ifNoProxies = pacProxyArray${pacMods.ifProxyOrDie ? '.length === 0' : '.every( (p) => /^DIRECT$/i.test(p) )'};
+/******/ if (ifNoProxies) {
+/******/ // Directs only or null, no proxies.
+/******/ return "DIRECT";
+/******/ }
+/******/ return ` +
+ function() {
+
+ if (!pacMods.ifUsePacScriptProxies) {
+ return '';
+ }
+ let filteredPacExp = 'pacScriptProxies';
+ if (pacMods.ifUseSecureProxiesOnly) {
+ filteredPacExp =
+ 'pacProxyArray.filter( (pStr) => /^HTTPS\\s/.test(pStr) ).join("; ")';
+ }
+ return filteredPacExp + ' + ';
+
+ }() + `${pacMods.filteredCustomsString ? 'filteredCustomProxies + ' : ''}directIfAllowed;`; // Without DIRECT you will get 'PROXY CONN FAILED' pac-error.
+
+ }()
+ }
};
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js
index fe0d5b0..2775f08 100644
--- a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js
+++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js
@@ -177,7 +177,7 @@
pacUrls: ['https://antizapret.prostovpn.org/proxy.pac'],
},
Антицензорити: {
- label: 'Антицензорити (тормозит)',
+ label: 'Антицензорити',
desc: 'Основной PAC-скрипт от автора расширения.' +
' Блокировка определятся по доменному имени или IP адресу.' +
' Работает на switch-ах.
' +
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/icons/default-grayscale-128.png b/extensions/chromium/runet-censorship-bypass/src/extension-common/icons/default-grayscale-128.png
index 277056b..eeadc19 100644
Binary files a/extensions/chromium/runet-censorship-bypass/src/extension-common/icons/default-grayscale-128.png and b/extensions/chromium/runet-censorship-bypass/src/extension-common/icons/default-grayscale-128.png differ
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/.gitignore b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/.gitignore
index 2966787..b7b476e 100644
--- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/.gitignore
+++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/.gitignore
@@ -1,4 +1,4 @@
node_modules
npm-debug.log
-.swp
+*.swp
dist
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/index.html b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/index.html
index a1d1577..1dccd73 100644
--- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/index.html
+++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/index.html
@@ -3,594 +3,22 @@