mirror of https://gitlab.com/bashrc2/epicyon
Improve support for federated blocks
parent
4233310044
commit
a5a6521c7d
|
@ -696,8 +696,8 @@ def _get_short_domain(domain: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def is_blocked_domain(base_dir: str, domain: str,
|
def is_blocked_domain(base_dir: str, domain: str,
|
||||||
blocked_cache: [] = None,
|
blocked_cache: [],
|
||||||
block_federated: [] = None) -> bool:
|
block_federated: []) -> bool:
|
||||||
"""Is the given domain blocked?
|
"""Is the given domain blocked?
|
||||||
"""
|
"""
|
||||||
if '.' not in domain:
|
if '.' not in domain:
|
||||||
|
|
|
@ -181,7 +181,8 @@ def blocked_user_agent(calling_domain: str, agent_str: str,
|
||||||
|
|
||||||
blocked_ua = \
|
blocked_ua = \
|
||||||
is_blocked_domain(base_dir, agent_domain,
|
is_blocked_domain(base_dir, agent_domain,
|
||||||
blocked_cache, block_federated)
|
blocked_cache, block_federated,
|
||||||
|
None, block_federated)
|
||||||
# if self.server.debug:
|
# if self.server.debug:
|
||||||
if blocked_ua:
|
if blocked_ua:
|
||||||
print('BLOCK: Blocked User agent 2: ' + agent_domain)
|
print('BLOCK: Blocked User agent 2: ' + agent_domain)
|
||||||
|
|
15
daemon.py
15
daemon.py
|
@ -2630,7 +2630,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.debug,
|
self.server.debug,
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
self.server.signing_priv_key_pem,
|
self.server.signing_priv_key_pem,
|
||||||
None)
|
None,
|
||||||
|
self.server.block_federated)
|
||||||
else:
|
else:
|
||||||
msg = \
|
msg = \
|
||||||
html_moderation_info(self.server.translate,
|
html_moderation_info(self.server.translate,
|
||||||
|
@ -3768,7 +3769,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.debug,
|
self.server.debug,
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
signing_priv_key_pem,
|
signing_priv_key_pem,
|
||||||
None)
|
None,
|
||||||
|
self.server.block_federated)
|
||||||
if msg:
|
if msg:
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -4088,7 +4090,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.debug,
|
self.server.debug,
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
self.server.signing_priv_key_pem,
|
self.server.signing_priv_key_pem,
|
||||||
users_path)
|
users_path,
|
||||||
|
self.server.block_federated)
|
||||||
if msg:
|
if msg:
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -21336,7 +21339,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.debug,
|
self.server.debug,
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
self.server.signing_priv_key_pem,
|
self.server.signing_priv_key_pem,
|
||||||
None)
|
None,
|
||||||
|
self.server.block_federated)
|
||||||
if msg:
|
if msg:
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -21378,7 +21382,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.debug,
|
self.server.debug,
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
self.server.signing_priv_key_pem,
|
self.server.signing_priv_key_pem,
|
||||||
None)
|
None,
|
||||||
|
self.server.block_federated)
|
||||||
if msg:
|
if msg:
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
|
12
newswire.py
12
newswire.py
|
@ -538,7 +538,7 @@ def _valid_podcast_entry(base_dir: str, key: str, entry: {}) -> bool:
|
||||||
post_domain, _ = get_domain_from_actor(post_url)
|
post_domain, _ = get_domain_from_actor(post_url)
|
||||||
if not post_domain:
|
if not post_domain:
|
||||||
return False
|
return False
|
||||||
if is_blocked_domain(base_dir, post_domain):
|
if is_blocked_domain(base_dir, post_domain, None, None):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -851,7 +851,7 @@ def _xml2str_to_dict(base_dir: str, domain: str, xml_str: str,
|
||||||
if '/' in item_domain:
|
if '/' in item_domain:
|
||||||
item_domain = item_domain.split('/')[0]
|
item_domain = item_domain.split('/')[0]
|
||||||
|
|
||||||
if is_blocked_domain(base_dir, item_domain):
|
if is_blocked_domain(base_dir, item_domain, None, None):
|
||||||
continue
|
continue
|
||||||
pub_date = rss_item.split('<pubDate>')[1]
|
pub_date = rss_item.split('<pubDate>')[1]
|
||||||
pub_date = pub_date.split('</pubDate>')[0]
|
pub_date = pub_date.split('</pubDate>')[0]
|
||||||
|
@ -965,7 +965,7 @@ def _xml1str_to_dict(base_dir: str, domain: str, xml_str: str,
|
||||||
if '/' in item_domain:
|
if '/' in item_domain:
|
||||||
item_domain = item_domain.split('/')[0]
|
item_domain = item_domain.split('/')[0]
|
||||||
|
|
||||||
if is_blocked_domain(base_dir, item_domain):
|
if is_blocked_domain(base_dir, item_domain, None, None):
|
||||||
continue
|
continue
|
||||||
pub_date = rss_item.split('<dc:date>')[1]
|
pub_date = rss_item.split('<dc:date>')[1]
|
||||||
pub_date = pub_date.split('</dc:date>')[0]
|
pub_date = pub_date.split('</dc:date>')[0]
|
||||||
|
@ -1072,7 +1072,7 @@ def _atom_feed_to_dict(base_dir: str, domain: str, xml_str: str,
|
||||||
if '/' in item_domain:
|
if '/' in item_domain:
|
||||||
item_domain = item_domain.split('/')[0]
|
item_domain = item_domain.split('/')[0]
|
||||||
|
|
||||||
if is_blocked_domain(base_dir, item_domain):
|
if is_blocked_domain(base_dir, item_domain, None, None):
|
||||||
continue
|
continue
|
||||||
pub_date = atom_item.split('<updated>')[1]
|
pub_date = atom_item.split('<updated>')[1]
|
||||||
pub_date = pub_date.split('</updated>')[0]
|
pub_date = pub_date.split('</updated>')[0]
|
||||||
|
@ -1185,7 +1185,7 @@ def _json_feed_v1to_dict(base_dir: str, domain: str, xml_str: str,
|
||||||
item_domain = link.split('://')[1]
|
item_domain = link.split('://')[1]
|
||||||
if '/' in item_domain:
|
if '/' in item_domain:
|
||||||
item_domain = item_domain.split('/')[0]
|
item_domain = item_domain.split('/')[0]
|
||||||
if is_blocked_domain(base_dir, item_domain):
|
if is_blocked_domain(base_dir, item_domain, None, None):
|
||||||
continue
|
continue
|
||||||
if json_feed_item.get('date_published'):
|
if json_feed_item.get('date_published'):
|
||||||
if not isinstance(json_feed_item['date_published'], str):
|
if not isinstance(json_feed_item['date_published'], str):
|
||||||
|
@ -1228,7 +1228,7 @@ def _atom_feed_yt_to_dict(base_dir: str, xml_str: str,
|
||||||
"""
|
"""
|
||||||
if '<entry>' not in xml_str:
|
if '<entry>' not in xml_str:
|
||||||
return {}
|
return {}
|
||||||
if is_blocked_domain(base_dir, 'www.youtube.com'):
|
if is_blocked_domain(base_dir, 'www.youtube.com', None, None):
|
||||||
return {}
|
return {}
|
||||||
result = {}
|
result = {}
|
||||||
atom_items = xml_str.split('<entry>')
|
atom_items = xml_str.split('<entry>')
|
||||||
|
|
|
@ -380,7 +380,7 @@ def post_message_to_outbox(session, translate: {},
|
||||||
test_domain, test_port = get_domain_from_actor(actor_url)
|
test_domain, test_port = get_domain_from_actor(actor_url)
|
||||||
if test_domain:
|
if test_domain:
|
||||||
test_domain = get_full_domain(test_domain, test_port)
|
test_domain = get_full_domain(test_domain, test_port)
|
||||||
if is_blocked_domain(base_dir, test_domain):
|
if is_blocked_domain(base_dir, test_domain, None, None):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: domain is blocked: ' + actor_url)
|
print('DEBUG: domain is blocked: ' + actor_url)
|
||||||
return False
|
return False
|
||||||
|
|
4
posts.py
4
posts.py
|
@ -913,7 +913,7 @@ def _get_posts_for_blocked_domains(base_dir: str,
|
||||||
get_domain_from_actor(reply_id)
|
get_domain_from_actor(reply_id)
|
||||||
if not post_domain:
|
if not post_domain:
|
||||||
continue
|
continue
|
||||||
if is_blocked_domain(base_dir, post_domain):
|
if is_blocked_domain(base_dir, post_domain, None, None):
|
||||||
if item['object'].get('url'):
|
if item['object'].get('url'):
|
||||||
url = get_url_from_post(item['object']['url'])
|
url = get_url_from_post(item['object']['url'])
|
||||||
else:
|
else:
|
||||||
|
@ -936,7 +936,7 @@ def _get_posts_for_blocked_domains(base_dir: str,
|
||||||
get_domain_from_actor(tag_url)
|
get_domain_from_actor(tag_url)
|
||||||
if not post_domain:
|
if not post_domain:
|
||||||
continue
|
continue
|
||||||
if is_blocked_domain(base_dir, post_domain):
|
if is_blocked_domain(base_dir, post_domain, None, None):
|
||||||
if item['object'].get('url'):
|
if item['object'].get('url'):
|
||||||
url = get_url_from_post(item['object']['url'])
|
url = get_url_from_post(item['object']['url'])
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -101,7 +101,8 @@ def html_account_info(translate: {},
|
||||||
nickname: str, domain: str, port: int,
|
nickname: str, domain: str, port: int,
|
||||||
search_handle: str, debug: bool,
|
search_handle: str, debug: bool,
|
||||||
system_language: str, signing_priv_key_pem: str,
|
system_language: str, signing_priv_key_pem: str,
|
||||||
back_url: str) -> str:
|
back_url: str,
|
||||||
|
block_federated: []) -> str:
|
||||||
"""Shows which domains a search handle interacts with.
|
"""Shows which domains a search handle interacts with.
|
||||||
This screen is shown if a moderator enters a handle and selects info
|
This screen is shown if a moderator enters a handle and selects info
|
||||||
on the moderation screen
|
on the moderation screen
|
||||||
|
@ -205,7 +206,7 @@ def html_account_info(translate: {},
|
||||||
http_prefix + '://' + post_domain + '" ' + \
|
http_prefix + '://' + post_domain + '" ' + \
|
||||||
'target="_blank" rel="nofollow noopener noreferrer">' + \
|
'target="_blank" rel="nofollow noopener noreferrer">' + \
|
||||||
post_domain + '</a> '
|
post_domain + '</a> '
|
||||||
if is_blocked_domain(base_dir, post_domain):
|
if is_blocked_domain(base_dir, post_domain, None, block_federated):
|
||||||
blocked_posts_links = ''
|
blocked_posts_links = ''
|
||||||
url_ctr = 0
|
url_ctr = 0
|
||||||
for url in blocked_post_urls:
|
for url in blocked_post_urls:
|
||||||
|
|
Loading…
Reference in New Issue