import bs4
+from fba.helpers import blacklist
from fba.helpers import config
from fba.helpers import domain as domain_helper
from fba.helpers import tidyup
logger = logging.getLogger(__name__)
#logger.setLevel(logging.DEBUG)
+# Lemmy translations
+translations = [
+ "Blocked Instances".lower(),
+ "Instàncies bloquejades".lower(),
+ "Blocáilte Ásc".lower(),
+ "封锁实例".lower(),
+ "Blokované instance".lower(),
+ "Geblokkeerde instanties".lower(),
+ "Blockerade instanser".lower(),
+ "Instàncias blocadas".lower(),
+ "Istanze bloccate".lower(),
+ "Instances bloquées".lower(),
+ "Letiltott példányok".lower(),
+ "Instancias bloqueadas".lower(),
+ "Blokeatuta dauden instantziak".lower(),
+ "차단된 인스턴스".lower(),
+ "Peladen Yang Diblokir".lower(),
+ "Blokerede servere".lower(),
+ "Blokitaj nodoj".lower(),
+ "Блокирани Инстанции".lower(),
+ "Blockierte Instanzen".lower(),
+ "Estetyt instanssit".lower(),
+ "Instâncias bloqueadas".lower(),
+ "Zablokowane instancje".lower(),
+ "Blokované inštancie".lower(),
+ "المثلاء المحجوبون".lower(),
+ "Užblokuoti serveriai".lower(),
+ "ブロックしたインスタンス".lower(),
+ "Блокированные Инстансы".lower(),
+ "Αποκλεισμένοι διακομιστές".lower(),
+ "封鎖站台".lower(),
+ "Instâncias bloqueadas".lower(),
+]
+
def fetch_peers(domain: str, origin: str) -> list:
logger.debug("domain='%s',origin='%s' - CALLED!", domain, origin)
domain_helper.raise_on(domain)
+ if blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function is invoked.")
+
peers = list()
# No CSRF by default, you don't have to add network.api_headers by yourself here
logger.debug("domain='%s - CALLED!", domain)
domain_helper.raise_on(domain)
- if not instances.is_registered(domain):
+ if blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function is invoked.")
+ elif not instances.is_registered(domain):
raise Exception(f"domain='{domain}' is not registered but function is invoked.")
- translations = [
- "Blocked Instances".lower(),
- "Instàncies bloquejades".lower(),
- "Blocáilte Ásc".lower(),
- "封锁实例".lower(),
- "Blokované instance".lower(),
- "Geblokkeerde instanties".lower(),
- "Blockerade instanser".lower(),
- "Instàncias blocadas".lower(),
- "Istanze bloccate".lower(),
- "Instances bloquées".lower(),
- "Letiltott példányok".lower(),
- "Instancias bloqueadas".lower(),
- "Blokeatuta dauden instantziak".lower(),
- "차단된 인스턴스".lower(),
- "Peladen Yang Diblokir".lower(),
- "Blokerede servere".lower(),
- "Blokitaj nodoj".lower(),
- "Блокирани Инстанции".lower(),
- "Blockierte Instanzen".lower(),
- "Estetyt instanssit".lower(),
- "Instâncias bloqueadas".lower(),
- "Zablokowane instancje".lower(),
- "Blokované inštancie".lower(),
- "المثلاء المحجوبون".lower(),
- "Užblokuoti serveriai".lower(),
- "ブロックしたインスタンス".lower(),
- "Блокированные Инстансы".lower(),
- "Αποκλεισμένοι διακομιστές".lower(),
- "封鎖站台".lower(),
- "Instâncias bloqueadas".lower(),
- ]
-
blocklist = list()
try:
content = str(header.contents[0])
logger.debug("content[%s]='%s' - AFTER!", type(content), content)
- if content is None:
+ if content is None or content == "":
logger.debug("domain='%s' has returned empty header='%s' - SKIPPED!", domain, header)
continue
elif not isinstance(content, str):
logger.debug("domain='%s',origin='%s' - CALLED!", domain, origin)
domain_helper.raise_on(domain)
+ if blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted but function is invoked.")
+
peers = list()
try: