mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
05cdd5194f
commit
8d880a4ea5
24
blocking.py
24
blocking.py
|
@ -39,7 +39,6 @@ from utils import has_users_path
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import remove_id_ending
|
from utils import remove_id_ending
|
||||||
from utils import locate_post
|
from utils import locate_post
|
||||||
from utils import evil_incarnate
|
|
||||||
from utils import get_domain_from_actor
|
from utils import get_domain_from_actor
|
||||||
from utils import get_nickname_from_actor
|
from utils import get_nickname_from_actor
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
@ -646,29 +645,6 @@ def is_blocked_hashtag(base_dir: str, hashtag: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_domain_blocklist(base_dir: str) -> str:
|
|
||||||
"""Returns all globally blocked domains as a string
|
|
||||||
This can be used for fast matching to mitigate flooding
|
|
||||||
"""
|
|
||||||
blocked_str: str = ''
|
|
||||||
|
|
||||||
evil_domains = evil_incarnate()
|
|
||||||
for evil in evil_domains:
|
|
||||||
blocked_str += evil + '\n'
|
|
||||||
|
|
||||||
global_blocking_filename = data_dir(base_dir) + '/blocking.txt'
|
|
||||||
if not os.path.isfile(global_blocking_filename):
|
|
||||||
return blocked_str
|
|
||||||
try:
|
|
||||||
with open(global_blocking_filename, 'r',
|
|
||||||
encoding='utf-8') as fp_blocked:
|
|
||||||
blocked_str += fp_blocked.read()
|
|
||||||
except OSError:
|
|
||||||
print('EX: get_domain_blocklist unable to read ' +
|
|
||||||
global_blocking_filename)
|
|
||||||
return blocked_str
|
|
||||||
|
|
||||||
|
|
||||||
def update_blocked_cache(base_dir: str,
|
def update_blocked_cache(base_dir: str,
|
||||||
blocked_cache: [],
|
blocked_cache: [],
|
||||||
blocked_cache_last_updated: int,
|
blocked_cache_last_updated: int,
|
||||||
|
|
|
@ -37,7 +37,6 @@ from blocking import load_blocked_bluesky
|
||||||
from blocking import load_blocked_nostr
|
from blocking import load_blocked_nostr
|
||||||
from blocking import update_blocked_cache
|
from blocking import update_blocked_cache
|
||||||
from blocking import set_broch_mode
|
from blocking import set_broch_mode
|
||||||
from blocking import get_domain_blocklist
|
|
||||||
from webapp_utils import load_buy_sites
|
from webapp_utils import load_buy_sites
|
||||||
from webapp_accesskeys import load_access_keys_for_accounts
|
from webapp_accesskeys import load_access_keys_for_accounts
|
||||||
from webapp_media import load_peertube_instances
|
from webapp_media import load_peertube_instances
|
||||||
|
@ -362,8 +361,6 @@ class EpicyonServer(ThreadingHTTPServer):
|
||||||
max_newswire_posts = 0
|
max_newswire_posts = 0
|
||||||
verify_all_signatures: bool = False
|
verify_all_signatures: bool = False
|
||||||
blocklistUpdateCtr = 0
|
blocklistUpdateCtr = 0
|
||||||
blocklistUpdateInterval = 100
|
|
||||||
domainBlocklist = None
|
|
||||||
manual_follower_approval = True
|
manual_follower_approval = True
|
||||||
onion_domain = None
|
onion_domain = None
|
||||||
i2p_domain = None
|
i2p_domain = None
|
||||||
|
@ -995,12 +992,6 @@ def run_daemon(accounts_data_dir: str,
|
||||||
# whether to require that all incoming posts have valid jsonld signatures
|
# whether to require that all incoming posts have valid jsonld signatures
|
||||||
httpd.verify_all_signatures = verify_all_signatures
|
httpd.verify_all_signatures = verify_all_signatures
|
||||||
|
|
||||||
# This counter is used to update the list of blocked domains in memory.
|
|
||||||
# It helps to avoid touching the disk and so improves flooding resistance
|
|
||||||
httpd.blocklistUpdateCtr = 0
|
|
||||||
httpd.blocklistUpdateInterval = 100
|
|
||||||
httpd.domainBlocklist = get_domain_blocklist(base_dir)
|
|
||||||
|
|
||||||
httpd.manual_follower_approval = manual_follower_approval
|
httpd.manual_follower_approval = manual_follower_approval
|
||||||
if domain.endswith('.onion'):
|
if domain.endswith('.onion'):
|
||||||
onion_domain = domain
|
onion_domain = domain
|
||||||
|
|
Loading…
Reference in New Issue