Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2022-01-30 18:58:13 +00:00
commit 2e5ec01e57
8 changed files with 86 additions and 17 deletions

View File

@ -939,7 +939,17 @@ def add_html_tags(base_dir: str, http_prefix: str,
custom_emoji_dict = \
load_json(base_dir + '/emojicustom/emoji.json')
if custom_emoji_dict:
emoji_dict = dict(emoji_dict, **custom_emoji_dict)
emojis_combined = True
try:
emoji_dict = dict(emoji_dict, **custom_emoji_dict)
except BaseException:
emojis_combined = False
if not emojis_combined:
# combine emoji dicts one by one
for ename, eitem in custom_emoji_dict.items():
if ename and eitem:
if not emoji_dict.get(ename):
emoji_dict[ename] = eitem
# print('TAG: looking up emoji for :' + word_str2 + ':')
_add_emoji(base_dir, ':' + word_str2 + ':', http_prefix,

View File

@ -245,6 +245,7 @@ from languages import set_actor_languages
from languages import get_understood_languages
from like import update_likes_collection
from reaction import update_reaction_collection
from utils import local_network_host
from utils import undo_reaction_collection_entry
from utils import get_new_post_endpoints
from utils import has_actor
@ -365,6 +366,7 @@ from fitnessFunctions import fitness_performance
from fitnessFunctions import fitness_thread
from fitnessFunctions import sorted_watch_points
from fitnessFunctions import html_watch_points_graph
from siteactive import site_is_active
import os
@ -1131,9 +1133,47 @@ class PubServer(BaseHTTPRequestHandler):
project_version, custom_emoji,
show_node_info_accounts)
def _nodeinfo(self, ua_str: str, calling_domain: str) -> bool:
def _nodeinfo(self, ua_str: str, calling_domain: str,
httpPrefix: str, calling_site_timeout: int,
debug: bool) -> bool:
if self.path.startswith('/nodeinfo/1.0'):
self._400()
return True
if not self.path.startswith('/nodeinfo/2.0'):
return False
if calling_domain == self.server.domain_full:
self._400()
return True
if self.server.nodeinfo_is_active:
print('nodeinfo is busy')
self._503()
return True
self.server.nodeinfo_is_active = True
# is this a real website making the call ?
if not debug and not self.server.unit_test:
# Does calling_domain look like a domain?
if ' ' in calling_domain or \
';' in calling_domain or \
'.' not in calling_domain:
print('nodeinfo calling domain does not look like a domain ' +
calling_domain)
self._400()
self.server.nodeinfo_is_active = False
return True
if not self.server.allow_local_network_access:
if local_network_host(calling_domain):
print('nodeinfo calling domain is from the ' +
'local network ' + calling_domain)
self._400()
self.server.nodeinfo_is_active = False
return True
if not site_is_active(httpPrefix + '://' + calling_domain,
calling_site_timeout):
print('nodeinfo calling domain is not active ' +
calling_domain)
self._400()
self.server.nodeinfo_is_active = False
return True
if self.server.debug:
print('DEBUG: nodeinfo ' + self.path)
self._update_known_crawlers(ua_str)
@ -1176,8 +1216,10 @@ class PubServer(BaseHTTPRequestHandler):
None, calling_domain, True)
self._write(msg)
print('nodeinfo sent to ' + calling_domain)
self.server.nodeinfo_is_active = False
return True
self._404()
self.server.nodeinfo_is_active = False
return True
def _webfinger(self, calling_domain: str) -> bool:
@ -13507,7 +13549,8 @@ class PubServer(BaseHTTPRequestHandler):
# Since fediverse crawlers are quite active,
# make returning info to them high priority
# get nodeinfo endpoint
if self._nodeinfo(ua_str, calling_domain):
if self._nodeinfo(ua_str, calling_domain,
self.server.http_prefix, 5, self.server.debug):
return
fitness_performance(getreq_start_time, self.server.fitness,
@ -18810,6 +18853,8 @@ def run_daemon(dyslexic_font: bool,
httpd.post_to_nickname = None
httpd.nodeinfo_is_active = False
httpd.dyslexic_font = dyslexic_font
# license for content of the instance

View File

@ -773,5 +773,7 @@
"kde": "kde",
"ohno": "ohno",
"lavabit": "lavabit",
"libreoffice": "libreoffice"
"libreoffice": "libreoffice",
"xmpp": "xmpp",
"jabber": "xmpp"
}

BIN
emoji/xmpp.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -791,6 +791,7 @@ def run_newswire_daemon(base_dir: str, httpd,
newswire_state_filename = base_dir + '/accounts/.newswirestate.json'
refresh_filename = base_dir + '/accounts/.refresh_newswire'
print('Starting newswire daemon')
# initial sleep to allow the system to start up
time.sleep(50)
while True:

View File

@ -1122,9 +1122,6 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
'conversation': conversation_id,
'type': post_object_type,
'summary': summary,
'summaryMap': {
system_language: summary
},
'inReplyTo': in_reply_to,
'published': published,
'url': new_post_url,
@ -1191,9 +1188,6 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int,
'conversation': conversation_id,
'type': post_object_type,
'summary': summary,
'summaryMap': {
system_language: summary
},
'inReplyTo': in_reply_to,
'published': published,
'url': new_post_url,
@ -1728,9 +1722,6 @@ def get_pinned_post_as_json(base_dir: str, http_prefix: str,
'replies': {},
'sensitive': False,
'summary': None,
'summaryMap': {
system_language: None
},
'tag': [],
'to': ['https://www.w3.org/ns/activitystreams#Public'],
'type': 'Note',
@ -2427,7 +2418,8 @@ def send_post(signing_priv_key_pem: str, project_version: str,
generate_json_signature(signed_post_json_object, private_key_pem)
post_json_object = signed_post_json_object
except Exception as ex:
print('WARN: failed to JSON-LD sign post, ' + str(ex))
print('WARN: send_post failed to JSON-LD sign post, ' + str(ex))
pprint(signed_post_json_object)
# convert json to string so that there are no
# subsequent conversions after creating message body digest
@ -2806,7 +2798,9 @@ def send_signed_json(post_json_object: {}, session, base_dir: str,
generate_json_signature(signed_post_json_object, private_key_pem)
post_json_object = signed_post_json_object
except BaseException as ex:
print('WARN: failed to JSON-LD sign post, ' + str(ex))
print('WARN: send_signed_json failed to JSON-LD sign post, ' +
str(ex))
pprint(signed_post_json_object)
# convert json to string so that there are no
# subsequent conversions after creating message body digest

View File

@ -179,7 +179,7 @@ def get_sha_512(msg: str):
return digest.finalize()
def _local_network_host(host: str) -> bool:
def local_network_host(host: str) -> bool:
"""Returns true if the given host is on the local network
"""
if host.startswith('localhost') or \
@ -196,7 +196,7 @@ def decoded_host(host: str) -> str:
"""
if ':' not in host:
# eg. mydomain:8000
if not _local_network_host(host):
if not local_network_host(host):
if not host.endswith('.onion'):
if not host.endswith('.i2p'):
return idna.decode(host)

View File

@ -65,6 +65,23 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
"allowfullscreen></iframe>\n</center>\n"
return content
video_site = 'https://youtu.be/'
if '"' + video_site in content:
url = content.split('"' + video_site)[1]
if '"' in url:
url = 'embed/' + url.split('"')[0]
if '&' in url:
url = url.split('&')[0]
if '?utm_' in url:
url = url.split('?utm_')[0]
content += \
"<center>\n<iframe loading=\"lazy\" src=\"" + \
video_site + url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"autoplay; fullscreen\" " + \
"allowfullscreen></iframe>\n</center>\n"
return content
invidious_sites = (
'https://invidious.snopyta.org',
'https://yewtu.be',