mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-27 11:53:44 +03:00
Merge branch 'whitelist' into development
This commit is contained in:
commit
235f6e4b47
File diff suppressed because it is too large
Load Diff
|
@ -9,7 +9,7 @@
|
|||
"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 release",
|
||||
"release": "npm run subpages && npm run gulp buildAll"
|
||||
"release": "npm run subpages && npx gulp -- buildAll"
|
||||
},
|
||||
"author": "Ilya Ig. Petrov",
|
||||
"license": "GPLv3",
|
||||
|
|
|
@ -101,12 +101,12 @@
|
|||
dflt: false,
|
||||
category: 'ownProxies',
|
||||
label: 'использовать СВОЙ локальный Tor',
|
||||
desc: 'Установите <a href="https://rebrand.ly/ac-tor">Tor</a> на свой компьютер и используйте его как прокси-сервер. <a href="https://rebrand.ly/ac-tor">ВАЖНО</a>',
|
||||
desc: 'Установите <a href="https://rebrand.ly/ac-tor">Tor</a> на свой компьютер и используйте его как прокси-сервер. <a href="https://rebrand.ly/ac-tor">ВАЖНО</a>.',
|
||||
order: 5,
|
||||
},
|
||||
exceptions: {
|
||||
category: 'exceptions',
|
||||
dflt: null,
|
||||
category: 'exceptions',
|
||||
},
|
||||
ifMindExceptions: {
|
||||
dflt: true,
|
||||
|
@ -115,6 +115,17 @@
|
|||
desc: 'Учитывать сайты, добавленные вручную. Только для своих прокси-серверов! Без своих прокси работать не будет.',
|
||||
order: 6,
|
||||
},
|
||||
whitelist: {
|
||||
dflt: [],
|
||||
category: 'exceptions',
|
||||
},
|
||||
ifMindWhitelist: {
|
||||
dflt: false,
|
||||
category: 'exceptions',
|
||||
label: 'Ограничиться только <a href="../exceptions/index.html">белым списком</a>',
|
||||
desc: 'Разрешить расширению работать только с адресами из белого списка.',
|
||||
order: 6.5,
|
||||
},
|
||||
customProxyStringRaw: {
|
||||
dflt: '',
|
||||
category: 'ownProxies',
|
||||
|
@ -157,7 +168,6 @@
|
|||
return acc;
|
||||
|
||||
}, {});
|
||||
|
||||
};
|
||||
|
||||
const getCurrentConfigs = function getCurrentConfigs(ifRaw = false) {
|
||||
|
@ -220,7 +230,8 @@
|
|||
});
|
||||
|
||||
const self = {};
|
||||
Object.assign(self, getDefaults(), mods);
|
||||
const gdft = getDefaults();
|
||||
Object.assign(self, gdft, mods);
|
||||
self.ifNoMods = ifNoMods;
|
||||
|
||||
let customProxyArray = [];
|
||||
|
@ -344,18 +355,32 @@
|
|||
/******/
|
||||
/******/ const originalFindProxyForURL = FindProxyForURL;
|
||||
/******/ let tmp = function(url, host) {
|
||||
/******/
|
||||
/******/ const dotHost = '.' + host;
|
||||
${
|
||||
function() {
|
||||
let generatedPac = `
|
||||
/******/ if (${pacMods.ifMindWhitelist && pacMods.whitelist.length}) {
|
||||
/******/ const ifWhitelisted =
|
||||
/******/ ${JSON.stringify(pacMods.whitelist)}.some((whiteHost) => {
|
||||
/******/ const ifWild = whiteHost.startsWith('*');
|
||||
/******/ if (ifWild) {
|
||||
/******/ return dotHost.endsWith(whiteHost.substr(1));
|
||||
/******/ }
|
||||
/******/ return host === whiteHost;
|
||||
/******/ })
|
||||
/******/ if (!ifWhitelisted) {
|
||||
/******/ return 'DIRECT';
|
||||
/******/ }
|
||||
/******/ }`;
|
||||
|
||||
let res = pacMods.ifProhibitDns ? `
|
||||
generatedPac += pacMods.ifProhibitDns ? `
|
||||
/******/
|
||||
/******/ global.dnsResolve = function(host) { return null; };
|
||||
/******/
|
||||
/******/` : '';
|
||||
if (pacMods.ifProxyHttpsUrlsOnly) {
|
||||
|
||||
res += `
|
||||
generatedPac += `
|
||||
/******/
|
||||
/******/ if (!url.startsWith("https")) {
|
||||
/******/ return "DIRECT";
|
||||
|
@ -365,7 +390,7 @@
|
|||
}
|
||||
if (pacMods.ifUseLocalTor) {
|
||||
|
||||
res += `
|
||||
generatedPac += `
|
||||
/******/
|
||||
/******/ if (host.endsWith(".onion")) {
|
||||
/******/ return "${pacMods.torPoints.join('; ')}";
|
||||
|
@ -373,12 +398,12 @@
|
|||
/******/
|
||||
/******/ `;
|
||||
}
|
||||
res += `
|
||||
generatedPac += `
|
||||
/******/
|
||||
/******/ const directIfAllowed = ${pacMods.ifProxyOrDie ? '""/* Not allowed. */' : '"DIRECT"'};
|
||||
/******/`;
|
||||
if (pacMods.filteredCustomsString) {
|
||||
res += `
|
||||
generatedPac += `
|
||||
/******/
|
||||
/******/ const filteredCustomProxies = "${pacMods.filteredCustomsString}";
|
||||
/******/`;
|
||||
|
@ -402,10 +427,9 @@
|
|||
const ifExceptions = Object.keys(finalExceptions).length;
|
||||
|
||||
if (ifExceptions) {
|
||||
res += `
|
||||
generatedPac += `
|
||||
/******/
|
||||
/******/ /* EXCEPTIONS START */
|
||||
/******/ const dotHost = '.' + host;
|
||||
// TODO: handle wildcards.
|
||||
/******/ const isHostInDomain = (domain, ifWild) => {
|
||||
if (ifWild) {
|
||||
|
@ -448,7 +472,7 @@ ${ pacMods.filteredCustomsString
|
|||
/******/ /* EXCEPTIONS END */
|
||||
`;
|
||||
}
|
||||
res += `
|
||||
generatedPac += `
|
||||
/******/ const pacScriptProxies = originalFindProxyForURL(url, host)${
|
||||
/******/ pacMods.ifProxyOrDie
|
||||
? '.replace(/DIRECT/g, "")'
|
||||
|
@ -459,12 +483,12 @@ ${ pacMods.filteredCustomsString
|
|||
!pacMods.filteredCustomsString &&
|
||||
pacMods.ifUsePacScriptProxies
|
||||
) {
|
||||
return res + `
|
||||
return generatedPac + `
|
||||
/******/ return [pacScriptProxies, directIfAllowed]
|
||||
.filter((p) => p).join("; ") || "DIRECT";`;
|
||||
}
|
||||
|
||||
return res + `
|
||||
return generatedPac + `
|
||||
/******/ 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) {
|
||||
|
|
|
@ -17,7 +17,9 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
|
|||
# Сначала идёт список проксируемых сайтов,
|
||||
# затем ==== на отдельной строке,
|
||||
# затем исключённые сайты.
|
||||
# После ещё одной строки с ==== идёт белый список.
|
||||
# Сортировка — с конца строки.
|
||||
# Адреса со звёздочками поддерживаются: *.kasparov.ru, например.
|
||||
|
||||
# ПРОКСИРОВАТЬ:
|
||||
|
||||
|
@ -26,7 +28,16 @@ ${(mods.included || []).join('\n')}
|
|||
===============================
|
||||
# НЕ ПРОКСИРОВАТЬ:
|
||||
|
||||
${(mods.excluded || []).join('\n')}`;
|
||||
${(mods.excluded || []).join('\n')}
|
||||
|
||||
|
||||
===============================
|
||||
# БЕЛЫЙ СПИСОК
|
||||
# Разрешить расширению работать только с этими адресами:
|
||||
|
||||
${(mods.whitelist || []).join('\n')}
|
||||
|
||||
`.trim();
|
||||
|
||||
status.innerText = 'Успешно загружено!';
|
||||
|
||||
|
@ -35,7 +46,7 @@ ${(mods.excluded || []).join('\n')}`;
|
|||
|
||||
saveBtn.onclick = function() {
|
||||
|
||||
let [proxyList, dontProxyList] = editor.value
|
||||
let [proxyList, dontProxyList, whitelist] = editor.value
|
||||
.trim()
|
||||
.replace(/#.*/g, '')
|
||||
.split(/=+/g)
|
||||
|
@ -45,12 +56,14 @@ ${(mods.excluded || []).join('\n')}`;
|
|||
.filter((host) => host)
|
||||
)
|
||||
dontProxyList = dontProxyList || [];
|
||||
whitelist = whitelist || [];
|
||||
|
||||
const exceptions = {};
|
||||
proxyList.forEach((host) => (exceptions[host] = true));
|
||||
dontProxyList.forEach((host) => (exceptions[host] = false));
|
||||
const mods = backgroundPage.apis.pacKitchen.getPacMods();
|
||||
mods.exceptions = exceptions;
|
||||
mods.whitelist = whitelist;
|
||||
backgroundPage.apis.pacKitchen.keepCookedNowAsync(mods, (err) => {
|
||||
if (!err) {
|
||||
status.innerText = 'Успешно сохранено!';
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,6 +12,7 @@
|
|||
"concat-stream": "^1.6.2",
|
||||
"csjs-inject": "^1.0.1",
|
||||
"flow-bin": "^0.45.0",
|
||||
"gulp": "^4.0.2",
|
||||
"inferno": "~3.2.0",
|
||||
"inferno-component": "^3.10.1",
|
||||
"inferno-create-element": "^3.10.1",
|
||||
|
|
Loading…
Reference in New Issue
Block a user