From 754c52983a87523374573ca6f1885d98f790fc33 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sun, 15 May 2022 20:27:28 +0300 Subject: [PATCH] Unchecked Authentication Requiring instances by default #248 --- src/assets/javascripts/helpers/common.js | 2 +- .../{cloudflare.json => blocklist.json} | 1 + src/instances/data.json | 6 ++--- src/instances/get_instances.py | 22 ++++++++++++++----- src/pages/background/background.js | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) rename src/instances/{cloudflare.json => blocklist.json} (97%) diff --git a/src/assets/javascripts/helpers/common.js b/src/assets/javascripts/helpers/common.js index 6e1c71f..4a264be 100644 --- a/src/assets/javascripts/helpers/common.js +++ b/src/assets/javascripts/helpers/common.js @@ -18,7 +18,7 @@ function getRandomInstance(instances) { let cloudflareList = []; async function initCloudflareList() { return new Promise(resolve => { - fetch('/instances/cloudflare.json').then(response => response.text()).then(data => { + fetch('/instances/blocklist').then(response => response.text()).then(data => { cloudflareList = JSON.parse(data); resolve(); }) diff --git a/src/instances/cloudflare.json b/src/instances/blocklist.json similarity index 97% rename from src/instances/cloudflare.json rename to src/instances/blocklist.json index 5424cc5..0e69e36 100644 --- a/src/instances/cloudflare.json +++ b/src/instances/blocklist.json @@ -9,6 +9,7 @@ "https://piped.mha.fi", "https://send.silkky.cloud", "https://nhanh.cloud", + "https://nitter.nixnet.services", "https://nitter.domain.glass", "https://birdsite.xanny.family", "https://nitter.moomoo.me", diff --git a/src/instances/data.json b/src/instances/data.json index d095e95..0cd02b7 100644 --- a/src/instances/data.json +++ b/src/instances/data.json @@ -2,7 +2,6 @@ "invidious": { "normal": [ "https://yewtu.be", - "https://vid.puffyan.us", "https://invidious.snopyta.org", "https://invidious.kavin.rocks", "https://inv.riverside.rocks", @@ -19,7 +18,8 @@ "https://invidious.weblibre.org", "https://invidious.esmailelbob.xyz", "https://youtube.076.ne.jp", - "https://invidious.namazso.eu" + "https://invidious.namazso.eu", + "https://vid.puffyan.us" ], "tor": [ "http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion", @@ -376,7 +376,6 @@ "https://searx.nixnet.services", "https://searx.openhoofd.nl", "https://searx.org", - "https://searx.ppeb.me", "https://searx.pwoss.org", "https://searx.rasp.fr", "https://searx.ru", @@ -444,6 +443,7 @@ "https://searx.mha.fi", "https://searx.namejeff.xyz", "https://searx.orion-hub.fr", + "https://searx.ppeb.me", "https://searx.prvcy.eu", "https://searx.sev.monster", "https://searx.tiekoetter.com", diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 7b62a9f..facbca6 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -67,6 +67,16 @@ def is_cloudflare(url): return False +def is_authenticate(url): + try: + r = requests.get(url, timeout=5) + if 'www-authenticate' in r.headers: + return True + except: + return False + return False + + def invidious(): r = requests.get('https://api.invidious.io/instances.json') rJson = json.loads(r.text) @@ -366,7 +376,7 @@ searx_searxng() whoogle() rimgo() -cloudflareMightyList = [] +blocklist = [] for k1, v1 in mightyList.items(): if type(mightyList[k1]) is dict: for k2, v2 in mightyList[k1].items(): @@ -376,7 +386,9 @@ for k1, v1 in mightyList.items(): # print("removed " + instance) # else: if not instance.endswith('.onion') and not instance.endswith('.i2p') and is_cloudflare(instance): - cloudflareMightyList.append(instance) + blocklist.append(instance) + if not instance.endswith('.onion') and not instance.endswith('.i2p') and is_authenticate(instance): + blocklist.append(instance) peertube() @@ -387,9 +399,9 @@ with open('./src/instances/data.json', 'w') as outfile: outfile.write(json_object) print(Fore.BLUE + 'wrote ' + Style.RESET_ALL + 'instances/data.json') -json_object = json.dumps(cloudflareMightyList, ensure_ascii=False, indent=2) -with open('./src/instances/cloudflare.json', 'w') as outfile: +json_object = json.dumps(blocklist, ensure_ascii=False, indent=2) +with open('./src/instances/blocklist.json', 'w') as outfile: outfile.write(json_object) -print(Fore.BLUE + 'wrote ' + Style.RESET_ALL + 'instances/cloudflare.json') +print(Fore.BLUE + 'wrote ' + Style.RESET_ALL + 'instances/blocklist') # print(json_object) diff --git a/src/pages/background/background.js b/src/pages/background/background.js index f7d0591..3c6efd3 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -22,7 +22,7 @@ window.browser = window.browser || window.chrome; browser.runtime.onInstalled.addListener(async details => { if (details.reason == 'install') { - fetch('/instances/cloudflare.json').then(response => response.text()).then(async data => { + fetch('/instances/blocklist.json').then(response => response.text()).then(async data => { await browser.storage.local.set({ cloudflareList: JSON.parse(data) }) youtubeHelper.initDefaults(); youtubeMusicHelper.initDefaults();