Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MarisKori authored May 4, 2019
1 parent e2809d7 commit 4750ee1
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 22 deletions.
7 changes: 5 additions & 2 deletions lib/domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,13 @@ var permanently_blocked = {
'kinogo.co':1, 'bobfilm.net':1, 'dream-film.net':1, 'kinokubik.com':1, 'kinozal.tv':1,
'kinobolt.ru':1, 'rutor.org':1, 'seedoff.net':1, 'torrentor.net':1, 'tushkan.net':1,
'tvserial-online.net':1, 'wood-film.ru':1, 'kinovo.tv':1, 'bigcinema.tv':1,
'rutracker.org':1,'rutracker.net':1,'rutracker.cr':1,'rutracker.nl':1,
'rutracker.org':1,'rutracker.net':1,'rutracker.cr':1,'rutracker.nl':1, 'rutracker.me':1,
'nnm-club.me':1, 'nnmclub.to':1,
'rutor.info':1, 'rutor.is':1,
'fast-torrent.ru':1, 'rustorka.com':1,
//13.11.2017 +10
'kinoprofi-online.club':1, 'bigcinema.club':1, 'vmuzike.ru':1, 'kinoleila.ru':1,
'my-hit.fm':1, 'kinobar.cc':1, 'bigcinema-online.ru':1, 'muzuka.me':1, 'kinogo-net.co':1,
}


Expand Down Expand Up @@ -177,7 +180,7 @@ const bad_domains = {
'rutreker-2018.org':1, 'gostracker.xyz':1,
};
const bad_domain_whitelist = {
'rutracker.wiki':1, 'rutracker.news':1, 'rutracker.org':1, 'rutracker.net':1, 'rutracker.cr':1, 'rutracker.nl':1,
'rutracker.wiki':1, 'rutracker.news':1, 'rutracker.org':1, 'rutracker.net':1, 'rutracker.cr':1, 'rutracker.nl':1, 'rutracker.me':1,
'rutrackerripnext.onion':1, 'rutracker.lib':1, 'rutracker.i2p':1,
'free-rutor.org':1, 'tor-ru.net':1,
'kinozal.guru':1, 'kinozal.me':1,
Expand Down
65 changes: 53 additions & 12 deletions lib/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ function setIcon_callback() {
}


let bl_rkn_sites = {}; //кэш фишинговых сайтов
let bl_rkn_sites_type = {};
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.type == "report") {
if (!bl_rkn_sites[request.host]) {
bl_rkn_sites[request.host] = request.status; //0 or 1
bl_rkn_sites_type[request.host] = request.name;
updateIcon();
}
}
});



//----------------------------- MANAGE ICON -----------------------------
Expand Down Expand Up @@ -54,6 +66,7 @@ function test_domain_mask(domain,masks) {
return false;
}

let rutracker_ip = {'195.82.146.214':1, };
let whitelist_ip_local_arr = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '127.0.0.1/24'];
let arr_special_url = {'about':1, };
chrome.browserAction.setBadgeBackgroundColor({color:"#777"});
Expand All @@ -80,6 +93,7 @@ function updateIcon(url, tabId) {
return;
} catch(e) { //Chrome
return chrome.tabs.getSelected(null, function(tab){ //getSelected deprecated!
if (!tab) return;
if (tab.url === undefined) return;
updateIcon(tab.url, tab.id);
});
Expand Down Expand Up @@ -146,6 +160,10 @@ function updateIcon(url, tabId) {
//if (!ip && extracted_blocked_ip) ip = extracted_blocked_ip; //info from provider!..
if (ip) {
icon_hint.ip = ip;
//rutracker?
if (rutracker_ip[ip] && domain != 'rutracker.org') {
icon_hint.is_personal_mirror = true;
}
//ip in whitelist?
if (whitelist.ip[ip] || isIp4InCidrs(ip,whitelist.ip_range)) icon_hint.is_whitelist_ip = true;
if (isIp4InCidrs(ip,whitelist_ip_local_arr)) icon_hint.is_whitelist_ip_local = true;
Expand Down Expand Up @@ -186,8 +204,20 @@ function updateIcon(url, tabId) {
if (whitelist.domain[icon_hint.hostname] || test_domain_mask(icon_hint.hostname,whitelist.domain_mask)) icon_hint.is_whitelist_domain = true;

//Test fishing sites
if ((bad_domains[domain] || domain.indexOf('rutracker') > -1) && !bad_domain_whitelist[domain]) {
if ((bad_domains[domain] || domain.indexOf('rutracker') > -1 || bl_rkn_sites[real_domain] === 0)
&& !bad_domain_whitelist[domain] && bl_rkn_sites[real_domain] !== 1) {
icon_hint.is_fishing = true;
//test if it's real rutracker.
let arr = Object.keys(icon_hint.ip_arr).sort();
if (arr.length > 0) {
if (rutracker_ip[arr[0]]) {
icon_hint.is_fishing = false;
icon_hint.is_personal_mirror = true;
}
}
} else if (bad_domain_whitelist[domain] || bl_rkn_sites[real_domain] === 1) {
icon_hint.not_fishing = true;
if (bl_rkn_sites[real_domain] === 1 && bl_rkn_sites_type[real_domain] === 'rutracker') icon_hint.is_personal_mirror = true;
}

//Check whois
Expand All @@ -201,7 +231,8 @@ function updateIcon(url, tabId) {
//check mask: *.example.com (in db it will be "example.com")
let test_domain = test_domain_mask(domain,database.blocked_mask);
if (test_domain) {
chrome.browserAction.setIcon({path: "images/circ_pink_red_16.png"});
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishingb_16.png"});
else chrome.browserAction.setIcon({path: "images/circ_pink_red_16.png"});
icon_hint.date = database.blocked_mask[test_domain];
icon_hint.text = "Заблокирована группа доменов *." + test_domain;
chrome.browserAction.setTitle({title:"*." + test_domain,tabId:tabId},setIcon_callback);
Expand All @@ -217,16 +248,19 @@ function updateIcon(url, tabId) {
if (is_ip_blocked === 3) icon_hint.text = "Заблокирована целая подсеть.";
else icon_hint.text = "Сайт заблокирован по ip";
chrome.browserAction.setTitle({title:"ip " + ip,tabId:tabId},setIcon_callback);
chrome.browserAction.setIcon({path: "images/circ_yellow_red_16.png"});
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishingb_16.png"});
else chrome.browserAction.setIcon({path: "images/circ_yellow_red_16.png"});
}
else if (status == 1) {
if (!icon_hint.is_whitelist_ip_local) icon_hint.text = "Некоторые провайдеры блокируют этот сайт по ip";
if (is_whitelist)
if (is_whitelist) {
//in whitelist (ignore status 1):
chrome.browserAction.setIcon({path: "images/circ_whitelist_16.png"});
else
} else {
chrome.browserAction.setTitle({title:"Не должно быть блокировки",tabId:tabId},setIcon_callback);
chrome.browserAction.setIcon({path: "images/circ_green_yellow_16.png"});
}
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishing_16.png"});
}
else chrome.browserAction.setIcon({path: "images/circ_unknown_16.png"});
return popup_update();
Expand All @@ -237,15 +271,18 @@ function updateIcon(url, tabId) {
if (icon_hint.reason_ip) icon_hint.date = icon_hint.reason_ip.date;
icon_hint.text = "Заблокирована целая подсеть.";
chrome.browserAction.setTitle({title:"Ковровая блокировка",tabId:tabId},setIcon_callback);
chrome.browserAction.setIcon({path: "images/circ_yellow_red_16.png"});
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishingb_16.png"});
else chrome.browserAction.setIcon({path: "images/circ_yellow_red_16.png"});
} else if (is_ip_blocked === 2) {
if (icon_hint.reason_ip) icon_hint.date = icon_hint.reason_ip.date;
icon_hint.text = "Блокировка по ip";
chrome.browserAction.setTitle({title:"Блокировка по ip",tabId:tabId},setIcon_callback);
chrome.browserAction.setIcon({path: "images/circ_yellow_red_16.png"});
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishingb_16.png"});
else chrome.browserAction.setIcon({path: "images/circ_yellow_red_16.png"});
} else if (is_ip_blocked === 1) {
if (!icon_hint.is_whitelist_ip_local) icon_hint.text = "Некоторые провайдеры блокируют этот сайт по ip";
if (is_whitelist)
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishing_16.png"});
else if (is_whitelist)
chrome.browserAction.setIcon({path: "images/circ_whitelist_16.png"});
else
chrome.browserAction.setIcon({path: "images/circ_green_yellow_16.png"});
Expand Down Expand Up @@ -283,11 +320,13 @@ function updateIcon(url, tabId) {
chrome.browserAction.setTitle({title:"Ссылка заблокирована",tabId:tabId},setIcon_callback);
if (rec.blocked) {
icon_hint.domain_blocked = true;
chrome.browserAction.setIcon({path: "images/circ_red_red_16.png"});
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishingb_16.png"});
else chrome.browserAction.setIcon({path: "images/circ_red_red_16.png"});
icon_hint.text = "URL и домен заблокированы.";
}
else {
chrome.browserAction.setIcon({path: "images/circ_red_white_16.png"});
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishing_16.png"});
else chrome.browserAction.setIcon({path: "images/circ_red_white_16.png"});
icon_hint.text = "URL заблокирован, но домен разрешён.";
}
return popup_update();
Expand All @@ -299,12 +338,14 @@ function updateIcon(url, tabId) {
postanovlenie: rec.postanovlenie,
gos_organ: rec.gos_organ,
};
chrome.browserAction.setIcon({path: "images/circ_pink_red_16.png"});
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishingb_16.png"});
else chrome.browserAction.setIcon({path: "images/circ_pink_red_16.png"});
chrome.browserAction.setTitle({title:"Домен заблокирован",tabId:tabId},setIcon_callback);
return popup_update();
}
//not blocked, but there are blocked URLs
chrome.browserAction.setIcon({path: "images/circ_orange_green_16.png"});
if (icon_hint.is_fishing) chrome.browserAction.setIcon({path: "images/circ_fishing_16.png"});
else chrome.browserAction.setIcon({path: "images/circ_orange_green_16.png"});
icon_hint.text = "На сайте есть заблокированные URL.";
popup_update();
}
Expand Down
25 changes: 17 additions & 8 deletions lib/is_site_online.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

let is_up_cache = {}; // {time:123, result:true}
const IS_UP_CACHE_TIMEOUT = 150000;
const IS_UP_CACHE_DN_TIMEOUT = 9000;

function check_if_is_online_cached(hostname) { //1 - online, 2-offline, 3-unknown, 4-loading
//console.log("check is cached",hostname);
if (is_up_cache[hostname]) {
let cache = is_up_cache[hostname];
let now = (new Date()).getTime();
if (now - cache.time < IS_UP_CACHE_TIMEOUT) {
if (now - cache.time < IS_UP_CACHE_TIMEOUT || cache.result != 1 && now - cache.time < IS_UP_CACHE_DN_TIMEOUT) {
//console.log(cache.result);
return cache.result;
}
Expand All @@ -31,15 +32,23 @@ function check_if_is_online(hostname, callback_update_site_status) {
}
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
//{"http":{"ip":"87.250.250.242","tm":0.05,"http":302,"rd":1,"res":3},"https":{"ip":"87.250.250.242","tm":0.16,"http":200,"e":42,"res":1}}
if (this.readyState == 4) {
//console.log("success");
let result;
if (this.status != 200) result = 3;
else if (xhr.responseText.indexOf('looks down from here') > -1 || xhr.responseText.indexOf("It's not just you!") > -1) { //down
result = 2;
} else if (xhr.responseText.indexOf(' is up') > -1 || xhr.responseText.indexOf("It's just you.") > -1) { //up
result = 1;
} else result = 3;
if (this.status != 200) result = 3; //unknown
else {
try {
let data = JSON.parse(xhr.responseText);
if (data.http.res < 0 || data.https.res < 0) {
console.log('check online error: ',xhr.responseText);
}
if (data.http.res >=5 && data.https.res >= 5) result = 2; //bad
else if (data.http.res <=4 && data.http.res > 0 || data.https.res <=4 && data.https.res > 0) result = 1; //good
else console.log(result = 3, xhr.responseText); //impossible
}
catch(e) { result = 3; }
}
is_up_cache[hostname] = {
time: (new Date()).getTime(),
result: result,
Expand All @@ -51,6 +60,6 @@ function check_if_is_online(hostname, callback_update_site_status) {
}
}
};
xhr.open("GET", 'https://downforeveryoneorjustme.com/'+hostname, true);
xhr.open("GET", 'http://h139775.s08.test-hf.su/ask-check.php?u='+hostname, true);
xhr.send();
}

0 comments on commit 4750ee1

Please sign in to comment.