From 8cf2602e61ef57ec7440ac05c80241eb3fd01d43 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Sun, 24 Feb 2019 17:12:41 +0000 Subject: [PATCH 1/4] Change warning message for anticensority pac-script --- .../37-sync-pac-script-with-pac-provider-api.tmpl.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 0aa70fb..56d88f8 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 @@ -127,9 +127,8 @@ addWarning( \` Не найдено СВОИХ прокси. Этот PAC-скрипт - теперь работает только со СВОИМИ прокси - (по умолчанию используется локальный TOR и прокси "Антизапрет", для их отключения: Свои прокси -> откл. "Использовать прокси PAC-скрипта"). + (по умолчанию будет использоваться локальный Tor). \`, ); } From 5d64e445fc47e8a47ca5e6c3f78a7a1fcc0b40d2 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Sun, 24 Feb 2019 17:17:09 +0000 Subject: [PATCH 2/4] Declare var near its usage --- .../37-sync-pac-script-with-pac-provider-api.tmpl.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 56d88f8..1a2afe4 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 @@ -138,7 +138,6 @@ httpLib.ifModifiedSince(pacUrl, lastModifiedStr, (err, newLastModifiedStr) => { if (!newLastModifiedStr) { - const res = {lastModified: lastModifiedStr}; const ifWasEverModified = lastModifiedStr !== new Date(0).toUTCString(); if (ifWasEverModified) { @@ -146,7 +145,7 @@ 'Ваш PAC-скрипт не нуждается в обновлении. Его дата: ' + lastModifiedStr ); - + const res = {lastModified: lastModifiedStr}; return cb(null, res); } } From 26fc0c4de36ba20ca4909cfe289523120c1d8406 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Tue, 26 Feb 2019 14:59:33 +0000 Subject: [PATCH 3/4] Add trailing comma to all the things --- ...c-pac-script-with-pac-provider-api.tmpl.js | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) 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 1a2afe4..a33cca2 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 @@ -58,7 +58,7 @@ }; const setPacAsync = function setPacAsync( - pacData = mandatory(), cb = throwIfError + pacData = mandatory(), cb = throwIfError, ) { const config = { @@ -80,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() ), ); } @@ -99,20 +99,20 @@ cb = asyncLogGroup( 'Getting IPs for PAC hosts...', - cb + cb, ); window.utils.fireRequest('ip-to-host-update-all', cb); }; const setPacScriptFromProviderAsync = function setPacScriptFromProviderAsync( - provider, lastModifiedStr = mandatory(), cb = throwIfError + provider, lastModifiedStr = mandatory(), cb = throwIfError, ) { const pacUrl = provider.pacUrls[0]; cb = asyncLogGroup( 'Getting PAC script from provider...', pacUrl, - cb + cb, ); const warnings = []; @@ -143,7 +143,7 @@ addWarning( 'Ваш PAC-скрипт не нуждается в обновлении. Его дата: ' + - lastModifiedStr + lastModifiedStr, ); const res = {lastModified: lastModifiedStr}; return cb(null, res); @@ -156,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( @@ -172,7 +172,7 @@ (err, res) => cb( err, Object.assign(res || {}, {lastModified: newLastModifiedStr}), - ) + ), ); }, @@ -229,7 +229,7 @@ order: 99, pacUrls: [ 'data:application/x-ns-proxy-autoconfig,' + escape('function FindProxyForURL(){ return "DIRECT"; }'), - ] + ], } }, @@ -290,7 +290,7 @@ setCurrentPacProviderKey( newKey = mandatory(), - lastModified = new Date().toUTCString() + lastModified = new Date().toUTCString(), ) { this.mustBeKey(newKey); @@ -330,7 +330,7 @@ chrome.storage.local.clear( () => chrome.storage.local.set( onlySettable, - chromified(cb) + chromified(cb), ) ); @@ -374,8 +374,8 @@ const ipsErrorPromise = new Promise( (resolve, reject) => updatePacProxyIps( - resolve - ) + resolve, + ), ); Promise.all([pacSetPromise, ipsErrorPromise]).then( @@ -389,7 +389,7 @@ warns.push(ipsErr); } this.pushToStorageAsync( - (pushErr) => cb(pacErr || pushErr, null, ...warns) + (pushErr) => cb(pacErr || pushErr, null, ...warns), ); }, @@ -416,7 +416,7 @@ console.log( 'Next PAC update is scheduled on', - new Date(nextUpdateMoment).toLocaleString('ru-RU') + new Date(nextUpdateMoment).toLocaleString('ru-RU'), ); chrome.alarms.create( @@ -459,11 +459,11 @@ } this.setCurrentPacProviderKey(null); this.pushToStorageAsync( - () => handlers.updateControlState(cb) + () => handlers.updateControlState(cb), ); - }) - ) + }), + ), ); }, @@ -491,7 +491,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 */}); } @@ -531,7 +531,7 @@ || antiCensorRu._currentPacProviderLastModified; console.log( 'Last PAC update was on', - new Date(antiCensorRu.lastPacUpdateStamp).toLocaleString('ru-RU') + new Date(antiCensorRu.lastPacUpdateStamp).toLocaleString('ru-RU'), ); From 4965921c06aa9cf2b9d95fcc22add6536e91b788 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Tue, 26 Feb 2019 15:26:47 +0000 Subject: [PATCH 4/4] Comment about having two dates for a pac provider --- .../37-sync-pac-script-with-pac-provider-api.tmpl.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 a33cca2..b554265 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 @@ -245,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() { @@ -257,7 +263,7 @@ }, - _currentPacProviderLastModified: 0, // Not initialized. + _currentPacProviderLastModified: 0, getLastModifiedForKey(key = mandatory()) {