Almost adds dns-over-https by google

This commit is contained in:
Ilya Ig. Petrov 2016-05-08 21:14:08 +05:00
parent 04d5dd2346
commit 43ff2c6164
210 changed files with 93 additions and 17 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
extensions/chromium/minimalistic-pac-setter/README.md Normal file → Executable file
View File

0
extensions/chromium/minimalistic-pac-setter/Support.md Normal file → Executable file
View File

View File

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
/* /*
Task 1. Gets IPs for proxies of antizapret/anticenz with dns-lg.com. Task 1. Gets IPs for proxies of antizapret/anticenz via dns over https.
These IPs are used in block-informer to inform user when proxy is ON. These IPs are used in block-informer to inform user when proxy is ON.
Task 2. Downloads PAC proxy script from antizapret/anticenz/my Google Drive and sets it in Chromium settings. Task 2. Downloads PAC proxy script from antizapret/anticenz/my Google Drive and sets it in Chromium settings.
Task 3. Schedules tasks 1 & 2 for every 4 hours. Task 3. Schedules tasks 1 & 2 for every 4 hours.
@ -11,7 +11,7 @@
In background scripts use window.antiCensorRu public variables. In background scripts use window.antiCensorRu public variables.
In pages window.antiCensorRu are not accessible, In pages window.antiCensorRu are not accessible,
use chrome.runtime.getBackgroundPage(..), use chrome.runtime.getBackgroundPage(..),
avoid old extension.getBackgroundPage. extension.getBackgroundPage is deprecated
*/ */
window.antiCensorRu = { window.antiCensorRu = {
@ -53,7 +53,7 @@ window.antiCensorRu = {
get currentPacProviderKey() { return this._currentPacProviderKey }, get currentPacProviderKey() { return this._currentPacProviderKey },
set currentPacProviderKey(newKey) { set currentPacProviderKey(newKey) {
if (newKey && !this.pacProviders[newKey]) if (newKey && !this.pacProviders[newKey])
throw new IllegalArgumentException('No provider for key:'+newKey); throw new IllegalArgumentException('No provider for key:' + newKey);
this._currentPacProviderKey = newKey; this._currentPacProviderKey = newKey;
}, },
@ -153,7 +153,7 @@ window.antiCensorRu = {
} }
); );
return nextUpdateMoment === now; // ifAlarmTriggered. May be changed. return nextUpdateMoment === now; // ifAlarmTriggered. May be changed in the future.
}, },
installPac(key, cb) { installPac(key, cb) {
@ -287,7 +287,22 @@ function httpGet(url, cb) {
); );
} }
function getIpsAndCnames(host, cb) { function _getIpsAndCnames(host, cb) {
/*
Answer format:
"answer":
[
{
"name": "proxy.antizapret.prostovpn.org.",
"type": "A",
"class": "IN",
"ttl": 409,
"rdlength": 4,
"rdata": "195.123.209.38"
}
...
CNAME example: ghs.google.com
**/
httpGet( httpGet(
'http://www.dns-lg.com/google1/'+ host +'/a', 'http://www.dns-lg.com/google1/'+ host +'/a',
(err, res) => { (err, res) => {
@ -296,8 +311,13 @@ function getIpsAndCnames(host, cb) {
res = JSON.parse(res); res = JSON.parse(res);
if (err) if (err)
err.clarification.message += ' Сервер: '+ res.message; err.clarification.message += ' Сервер: '+ res.message;
else else {
res = res.answer; res = res.answer;
for (const r of res) {
r.data = r.rdata;
delete r.rdata;
}
}
} catch(e) { } catch(e) {
err = err || {clarification:{message:''}}; err = err || {clarification:{message:''}};
err.clarification.message += ' Сервер: '+ res; err.clarification.message += ' Сервер: '+ res;
@ -308,6 +328,62 @@ function getIpsAndCnames(host, cb) {
); );
} }
function getIpsAndCnames(host, cb) {
/*
Answer format:
"Answer":
[
{
"name": "apple.com.", // Always matches name in the Question section
"type": 1, // A - Standard DNS RR type
"TTL": 3599, // Record's time-to-live in seconds
"data": "17.178.96.59" // Data for A - IP address as text
},
...
**/
const type2str = {
// https://en.wikipedia.org/wiki/List_of_DNS_record_types
1: 'A',
2: 'NS',
28: 'AAAA',
5: 'CNAME'
};
httpGet(
'https://dns.google.com/resolve?type=A&name=' + host
(err, res) => {
if (res) {
try {
res = JSON.parse(res);
if (err || res.Status) {
const msg = ['Answer', 'Comment', 'Status']
.filter( (prop) => res[ prop ] )
.map( (prop) => prop + ': ' + JSON.stringify( res[ prop ] ) )
.join(', \n');
err.clarification.message += ' Сервер: '+ msg;
err.data = err.data || res;
}
else {
res = res.Answer;
for (const r of res) {
r.type = type2str[ r.type ];
}
}
}
catch(e) {
err = err || {clarification:{message:''}};
err.clarification.message += ' Сервер: '+ res;
err.clarification.message.trim();
err.data = err.data || res;
}
}
return cb( err, res );
}
);
}
function updatePacProxyIps(provider, cb) { function updatePacProxyIps(provider, cb) {
var cb = asyncLogGroup('Getting IP for '+ provider.proxyHosts.join(', ') +'...', cb); var cb = asyncLogGroup('Getting IP for '+ provider.proxyHosts.join(', ') +'...', cb);
var failure = { var failure = {
@ -321,7 +397,7 @@ function updatePacProxyIps(provider, cb) {
(err, ans) => { (err, ans) => {
if (!err) { if (!err) {
provider.proxyIps = provider.proxyIps || {}; provider.proxyIps = provider.proxyIps || {};
ans.filter( ans => ans.type === 'A' ).map( ans => provider.proxyIps[ ans.rdata ] = proxyHost ); ans.filter( ans => ans.type === 'A' ).map( ans => provider.proxyIps[ ans.data ] = proxyHost );
} else } else
failure.errors[proxyHost] = err; failure.errors[proxyHost] = err;

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

View File

@ -12,13 +12,13 @@ chrome.runtime.getBackgroundPage( backgroundPage => {
${err.clarification && err.clarification.message || err.message}` ${err.clarification && err.clarification.message || err.message}`
) )
: records.length === 1 && records[0].type === 'A' : records.length === 1 && records[0].type === 'A'
? window.location.replace( backgroundPage.reestrUrl + records[0].rdata ) ? window.location.replace( backgroundPage.reestrUrl + records[0].data )
: document.write( : document.write(
'<title>Выбор IP</title>' '<title>Выбор IP</title>'
+ '<h4>У домена несколько IP / синонимов:</h4>' + '<h4>У домена несколько IP / синонимов:</h4>'
+ records + records
.sort( (a,b) => a.rdata.localeCompare(b.rdata) ) .sort( (a,b) => a.data.localeCompare(b.data) )
.map( ans => ans.rdata.link( ans.type === 'A' ? backgroundPage.reestrUrl + ans.rdata : window.location.pathname +'?'+ ans.rdata ) ) .map( ans => ans.data.link( ans.type === 'A' ? backgroundPage.reestrUrl + ans.data : window.location.pathname +'?'+ ans.data ) )
.join('<br/>') .join('<br/>')
) )
) )

0
extensions/chromium/pac-generator-extension/README.md Normal file → Executable file
View File

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

0
extensions/chromium/pac-generator-extension/index.html Normal file → Executable file
View File

View File

View File

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 226 B

View File

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 226 B

View File

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 240 B

View File

Before

Width:  |  Height:  |  Size: 894 B

After

Width:  |  Height:  |  Size: 894 B

View File

Before

Width:  |  Height:  |  Size: 502 B

After

Width:  |  Height:  |  Size: 502 B

View File

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 226 B

View File

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

View File

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 226 B

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 241 B

View File

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 228 B

View File

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 225 B

After

Width:  |  Height:  |  Size: 225 B

View File

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 228 B

View File

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 236 B

View File

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 228 B

View File

Before

Width:  |  Height:  |  Size: 997 B

After

Width:  |  Height:  |  Size: 997 B

View File

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 222 B

View File

Before

Width:  |  Height:  |  Size: 432 B

After

Width:  |  Height:  |  Size: 432 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 218 B

View File

Before

Width:  |  Height:  |  Size: 244 B

After

Width:  |  Height:  |  Size: 244 B

View File

Before

Width:  |  Height:  |  Size: 636 B

After

Width:  |  Height:  |  Size: 636 B

View File

Before

Width:  |  Height:  |  Size: 221 B

After

Width:  |  Height:  |  Size: 221 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 602 B

After

Width:  |  Height:  |  Size: 602 B

View File

Before

Width:  |  Height:  |  Size: 456 B

After

Width:  |  Height:  |  Size: 456 B

View File

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 640 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 921 B

After

Width:  |  Height:  |  Size: 921 B

View File

Before

Width:  |  Height:  |  Size: 926 B

After

Width:  |  Height:  |  Size: 926 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 311 B

View File

Before

Width:  |  Height:  |  Size: 242 B

After

Width:  |  Height:  |  Size: 242 B

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Some files were not shown because too many files have changed in this diff Show More