diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 index 6ff4ce6..12f07a4 --- a/README.md +++ b/README.md @@ -23,15 +23,15 @@ My maxim is _"Your freedom ends when it starts to confine the freedom of others" 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), +Looking at how Russian government [distorts TV](https://therussianreader.wordpress.com/2015/11/22/russian-truckers-strike-dagestan/) and blocks [critics of Putin](https://www.reuters.com/article/us-russia-internet-idUSBREA2C21L20140313), I decided to write an anticensorship extension for Chromium before they strike me first. ## How it Works 0. PAC script is a JavaScript file, triggered on every URL request, which says browser which proxy to use if any for this particular URL. -1. The Chrome Extension sets PAC script in browser settings and keeps it synced with PAC script on the server (offering Antizapret (hosted on a dedicated server) or Anticensority (hosted on GitHub + CloudFlare)). +1. The Chrome Extension sets PAC script in browser settings and keeps it synced with PAC script on the server (offering Antizapret (hosted on a dedicated server) or Anticensority (hosted on GitHub)). 2. On every request PAC script checks if host is blocked or if its IP is blocked. -3. If address is blocked PAC script returns proxy server to the browser, both Antizapret and Anticensority use Antizapret proxy servers. +3. If address is blocked PAC script returns proxy server to the browser. Antizapret PAC-script uses its own proxy servers and Anticensority PAC-script uses local Tor. 4. PAC scripts on servers are updated periodically from https://github.com/zapret-info/z-i. ## Contributors diff --git a/extensions/chromium/runet-censorship-bypass/README.md b/extensions/chromium/runet-censorship-bypass/README.md index 2243bc0..c17e3a3 100644 --- a/extensions/chromium/runet-censorship-bypass/README.md +++ b/extensions/chromium/runet-censorship-bypass/README.md @@ -1,12 +1,20 @@ # Install +Tested on NodeJS versoin: 12. + ``` npm install cd src/extension-common/pages/options/ npm install cd - -npm start -use your build/extension-beta + +# For debugging: +npm start +# Use your build/extension-beta + +# For production: +npm run release +# Use your build/extension-full or build/extension-mini ``` # Release 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 2189525..9635aed 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 @@ -122,6 +122,13 @@ url: 'https://rebrand.ly/ac-own-proxy', order: 7, }, + ifUseOwnProxiesOnlyForOwnSites: { + dflt: false, + category: 'ownProxies', + label: 'СВОИ прокси только для СВОИХ сайтов', + desc: 'Не использовать СВОИ прокси для всех сайтов из PAC-скрипта, а только для добавленных вручную исключений.', + order: 7.5, + }, ifProxyMoreDomains: { ifDisabled: true, dflt: false, @@ -451,7 +458,7 @@ ${ pacMods.filteredCustomsString /******/ return "DIRECT"; /******/ } /******/ return ` + - (pacMods.filteredCustomsString + ((pacMods.filteredCustomsString && !pacMods.ifUseOwnProxiesOnlyForOwnSites) ? 'filteredCustomProxies + "; " + ' : '' ) + diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js index c637ac7..b263b2b 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js @@ -145,20 +145,28 @@ httpLib.ifModifiedSince(pacUrl, lastModifiedStr, (err, newLastModifiedStr) => { - if (!newLastModifiedStr) { - const ifWasEverModified = lastModifiedStr !== new Date(0).toUTCString(); - if (ifWasEverModified) { + /* + TODO: Get rid of this dirty hack + IPFS used by AntiZapret always returns last-modified date as new Date(1000) which is 1 sec since unix epoch. + Last-modified isn't changed but target redireciton URL is and this URL should be compared to the last cached URL. + Hack here is to consider 5 seconds since epoch time the same way as the unix epoch start. + If you think etags are the solution then know that etags can't be read from the fetch API, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers. + */ + /* + TODO: I turn off caching for now because I see no easy way out. - addWarning( - (ifRu - ? 'Ваш PAC-скрипт не нуждается в обновлении. Его дата: ' - : 'Your PAC-script doesn\\'t need to be updated. It\\'s date: ' - ) + lastModifiedStr, - ); - const res = {lastModified: lastModifiedStr}; - return cb(null, res); - } + const ifWasEverModified = new Date(lastModifiedStr) - new Date(0) > 5000; + if (!newLastModifiedStr && ifWasEverModified) { + addWarning( + (ifRu + ? 'Ваш PAC-скрипт не нуждается в обновлении. Его дата: ' + : 'Your PAC-script doesn\\'t need to be updated. It\\'s date: ' + ) + lastModifiedStr, + ); + const res = {lastModified: lastModifiedStr}; + return cb(null, res); } + */ // Employ all urls, the latter are fallbacks for the former. const pacDataPromise = provider.pacUrls.reduce( diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/manifest.tmpl.json b/extensions/chromium/runet-censorship-bypass/src/extension-common/manifest.tmpl.json index 7f19801..0f75361 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/manifest.tmpl.json +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/manifest.tmpl.json @@ -6,7 +6,7 @@ "description": "__MSG_extDesc__", "version": "0.0.${version}", "icons": { - "128": "/icons/default-128.png" + "128": "icons/default-128.png" }, "author": "anticensority+owners@googlegroups.com", diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ExcEditor.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ExcEditor.js index 12fc36c..13959fb 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ExcEditor.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ExcEditor.js @@ -79,7 +79,7 @@ export default function getExcEditor(theState) { props.currentTab && props.currentTab.url && !props.currentTab.url.startsWith('chrome') - ? new URL(props.currentTab.url).hostname + ? new URL(props.currentTab.url).hostname.replace(/^www\./g, '') : ''; const pacMods = props.apis.pacKitchen.getPacMods(); diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Footer.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Footer.js index 4476546..51dee19 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Footer.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Footer.js @@ -1,7 +1,7 @@ import Inferno from 'inferno'; import css from 'csjs-inject'; -export default function getFooter() { +export default function getFooter(theState) { const scopedCss = css` @@ -26,7 +26,7 @@ export default function getFooter() {