mirror of https://gitlab.com/bashrc2/epicyon
Get correct domain for private key when using onion or i2p json send
parent
406ab7add3
commit
74dc33b96a
14
announce.py
14
announce.py
|
@ -141,7 +141,9 @@ def create_announce(session, base_dir: str, federation_list: [],
|
|||
send_threads: [], postLog: [],
|
||||
person_cache: {}, cached_webfingers: {},
|
||||
debug: bool, project_version: str,
|
||||
signing_priv_key_pem: str) -> {}:
|
||||
signing_priv_key_pem: str,
|
||||
curr_domain: str,
|
||||
onion_domain: str, i2p_domain: str) -> {}:
|
||||
"""Creates an announce message
|
||||
Typically to_url will be https://www.w3.org/ns/activitystreams#Public
|
||||
and ccUrl might be a specific person favorited or repeated and the
|
||||
|
@ -202,7 +204,8 @@ def create_announce(session, base_dir: str, federation_list: [],
|
|||
send_threads, postLog, cached_webfingers,
|
||||
person_cache,
|
||||
debug, project_version, None, group_account,
|
||||
signing_priv_key_pem, 639633)
|
||||
signing_priv_key_pem, 639633,
|
||||
curr_domain, onion_domain, i2p_domain)
|
||||
|
||||
return new_announce
|
||||
|
||||
|
@ -213,7 +216,9 @@ def announce_public(session, base_dir: str, federation_list: [],
|
|||
send_threads: [], postLog: [],
|
||||
person_cache: {}, cached_webfingers: {},
|
||||
debug: bool, project_version: str,
|
||||
signing_priv_key_pem: str) -> {}:
|
||||
signing_priv_key_pem: str,
|
||||
curr_domain: str,
|
||||
onion_domain: str, i2p_domain: str) -> {}:
|
||||
"""Makes a public announcement
|
||||
"""
|
||||
from_domain = get_full_domain(domain, port)
|
||||
|
@ -227,7 +232,8 @@ def announce_public(session, base_dir: str, federation_list: [],
|
|||
send_threads, postLog,
|
||||
person_cache, cached_webfingers,
|
||||
debug, project_version,
|
||||
signing_priv_key_pem)
|
||||
signing_priv_key_pem, curr_domain,
|
||||
onion_domain, i2p_domain)
|
||||
|
||||
|
||||
def send_announce_via_server(base_dir: str, session,
|
||||
|
|
10
daemon.py
10
daemon.py
|
@ -3412,7 +3412,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.cached_webfingers,
|
||||
self.server.person_cache, debug,
|
||||
self.server.project_version,
|
||||
self.server.signing_priv_key_pem)
|
||||
self.server.signing_priv_key_pem,
|
||||
self.server.domain,
|
||||
self.server.onion_domain,
|
||||
self.server.i2p_domain)
|
||||
if calling_domain.endswith('.onion') and onion_domain:
|
||||
origin_path_str = 'http://' + onion_domain + users_path
|
||||
elif (calling_domain.endswith('.i2p') and i2p_domain):
|
||||
|
@ -8306,7 +8309,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.cached_webfingers,
|
||||
debug,
|
||||
self.server.project_version,
|
||||
self.server.signing_priv_key_pem)
|
||||
self.server.signing_priv_key_pem,
|
||||
self.server.domain,
|
||||
self.server.onion_domain,
|
||||
self.server.i2p_domain)
|
||||
announce_filename = None
|
||||
if announce_json:
|
||||
# save the announce straight to the outbox
|
||||
|
|
20
follow.py
20
follow.py
|
@ -731,7 +731,9 @@ def followed_account_accepts(session, base_dir: str, http_prefix: str,
|
|||
cached_webfingers: {}, person_cache: {},
|
||||
debug: bool, project_version: str,
|
||||
removeFollowActivity: bool,
|
||||
signing_priv_key_pem: str):
|
||||
signing_priv_key_pem: str,
|
||||
curr_domain: str,
|
||||
onion_domain: str, i2p_domain: str):
|
||||
"""The person receiving a follow request accepts the new follower
|
||||
and sends back an Accept activity
|
||||
"""
|
||||
|
@ -780,10 +782,12 @@ def followed_account_accepts(session, base_dir: str, http_prefix: str,
|
|||
send_threads, postLog, cached_webfingers,
|
||||
person_cache, debug, project_version, None,
|
||||
group_account, signing_priv_key_pem,
|
||||
7856837)
|
||||
7856837, curr_domain, onion_domain, i2p_domain)
|
||||
|
||||
|
||||
def followed_account_rejects(session, base_dir: str, http_prefix: str,
|
||||
def followed_account_rejects(session, session_onion, session_i2p,
|
||||
onion_domain: str, i2p_domain: str,
|
||||
base_dir: str, http_prefix: str,
|
||||
nickname_to_follow: str, domain_to_follow: str,
|
||||
port: int,
|
||||
nickname: str, domain: str, from_port: int,
|
||||
|
@ -848,7 +852,8 @@ def followed_account_rejects(session, base_dir: str, http_prefix: str,
|
|||
send_threads, postLog, cached_webfingers,
|
||||
person_cache, debug, project_version, None,
|
||||
group_account, signing_priv_key_pem,
|
||||
6393063)
|
||||
6393063,
|
||||
domain, onion_domain, i2p_domain)
|
||||
|
||||
|
||||
def send_follow_request(session, base_dir: str,
|
||||
|
@ -861,7 +866,9 @@ def send_follow_request(session, base_dir: str,
|
|||
client_to_server: bool, federation_list: [],
|
||||
send_threads: [], postLog: [], cached_webfingers: {},
|
||||
person_cache: {}, debug: bool,
|
||||
project_version: str, signing_priv_key_pem: str) -> {}:
|
||||
project_version: str, signing_priv_key_pem: str,
|
||||
curr_domain: str,
|
||||
onion_domain: str, i2p_domain: str) -> {}:
|
||||
"""Gets the json object for sending a follow request
|
||||
"""
|
||||
if not signing_priv_key_pem:
|
||||
|
@ -942,7 +949,8 @@ def send_follow_request(session, base_dir: str,
|
|||
federation_list,
|
||||
send_threads, postLog, cached_webfingers, person_cache,
|
||||
debug, project_version, None, group_account,
|
||||
signing_priv_key_pem, 8234389)
|
||||
signing_priv_key_pem, 8234389,
|
||||
curr_domain, onion_domain, i2p_domain)
|
||||
|
||||
return new_follow_json
|
||||
|
||||
|
|
26
inbox.py
26
inbox.py
|
@ -2664,6 +2664,7 @@ def _send_to_group_members(session, session_onion, session_i2p,
|
|||
cached_webfingers: {},
|
||||
person_cache: {}, debug: bool,
|
||||
system_language: str,
|
||||
curr_domain: str,
|
||||
onion_domain: str, i2p_domain: str,
|
||||
signing_priv_key_pem: str) -> None:
|
||||
"""When a post arrives for a group send it out to the group members
|
||||
|
@ -2716,7 +2717,8 @@ def _send_to_group_members(session, session_onion, session_i2p,
|
|||
http_prefix, post_id, False, False,
|
||||
send_threads, post_log,
|
||||
person_cache, cached_webfingers,
|
||||
debug, __version__, signing_priv_key_pem)
|
||||
debug, __version__, signing_priv_key_pem,
|
||||
curr_domain, onion_domain, i2p_domain)
|
||||
|
||||
send_to_followers_thread(session, session_onion, session_i2p,
|
||||
base_dir, nickname, domain,
|
||||
|
@ -2854,7 +2856,8 @@ def _bounce_dm(senderPostId: str, session, http_prefix: str,
|
|||
signing_priv_key_pem: str,
|
||||
content_license_url: str,
|
||||
languages_understood: [],
|
||||
bounce_is_chat: bool) -> bool:
|
||||
bounce_is_chat: bool,
|
||||
curr_domain: str, onion_domain: str, i2p_domain: str) -> bool:
|
||||
"""Sends a bounce message back to the sending handle
|
||||
if a DM has been rejected
|
||||
"""
|
||||
|
@ -2928,7 +2931,8 @@ def _bounce_dm(senderPostId: str, session, http_prefix: str,
|
|||
http_prefix, False, False, federation_list,
|
||||
send_threads, post_log, cached_webfingers,
|
||||
person_cache, debug, __version__, None, group_account,
|
||||
signing_priv_key_pem, 7238634)
|
||||
signing_priv_key_pem, 7238634,
|
||||
curr_domain, onion_domain, i2p_domain)
|
||||
return True
|
||||
|
||||
|
||||
|
@ -2944,7 +2948,8 @@ def _is_valid_dm(base_dir: str, nickname: str, domain: str, port: int,
|
|||
handle: str, system_language: str,
|
||||
signing_priv_key_pem: str,
|
||||
content_license_url: str,
|
||||
languages_understood: []) -> bool:
|
||||
languages_understood: [],
|
||||
curr_domain: str, onion_domain: str, i2p_domain: str) -> bool:
|
||||
"""Is the given message a valid DM?
|
||||
"""
|
||||
if nickname == 'inbox':
|
||||
|
@ -3031,7 +3036,9 @@ def _is_valid_dm(base_dir: str, nickname: str, domain: str, port: int,
|
|||
signing_priv_key_pem,
|
||||
content_license_url,
|
||||
languages_understood,
|
||||
bounce_chat)
|
||||
bounce_chat,
|
||||
curr_domain,
|
||||
onion_domain, i2p_domain)
|
||||
return False
|
||||
|
||||
# dm index will be updated
|
||||
|
@ -3559,7 +3566,9 @@ def _inbox_after_initial(recent_posts_cache: {}, max_recent_posts: int,
|
|||
handle, system_language,
|
||||
signing_priv_key_pem,
|
||||
content_license_url,
|
||||
languages_understood):
|
||||
languages_understood,
|
||||
domain,
|
||||
onion_domain, i2p_domain):
|
||||
return False
|
||||
|
||||
# get the actor being replied to
|
||||
|
@ -3701,7 +3710,7 @@ def _inbox_after_initial(recent_posts_cache: {}, max_recent_posts: int,
|
|||
post_log, cached_webfingers,
|
||||
person_cache,
|
||||
debug, system_language,
|
||||
onion_domain, i2p_domain,
|
||||
domain, onion_domain, i2p_domain,
|
||||
signing_priv_key_pem)
|
||||
|
||||
# if the post wasn't saved
|
||||
|
@ -4190,7 +4199,8 @@ def _receive_follow_request(session, session_onion, session_i2p,
|
|||
message_json, send_threads, post_log,
|
||||
cached_webfingers, person_cache,
|
||||
debug, project_version, True,
|
||||
signing_priv_key_pem)
|
||||
signing_priv_key_pem,
|
||||
curr_domain, onion_domain, i2p_domain)
|
||||
|
||||
|
||||
def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
|
||||
|
|
13
like.py
13
like.py
|
@ -77,7 +77,9 @@ def _create_like(recent_posts_cache: {},
|
|||
send_threads: [], postLog: [],
|
||||
person_cache: {}, cached_webfingers: {},
|
||||
debug: bool, project_version: str,
|
||||
signing_priv_key_pem: str) -> {}:
|
||||
signing_priv_key_pem: str,
|
||||
curr_domain: str,
|
||||
onion_domain: str, i2p_domain: str) -> {}:
|
||||
"""Creates a like
|
||||
actor is the person doing the liking
|
||||
'to' might be a specific person (actor) whose post was liked
|
||||
|
@ -142,7 +144,8 @@ def _create_like(recent_posts_cache: {},
|
|||
send_threads, postLog, cached_webfingers,
|
||||
person_cache,
|
||||
debug, project_version, None, group_account,
|
||||
signing_priv_key_pem, 7367374)
|
||||
signing_priv_key_pem, 7367374,
|
||||
curr_domain, onion_domain, i2p_domain)
|
||||
|
||||
return new_like_json
|
||||
|
||||
|
@ -156,7 +159,8 @@ def like_post(recent_posts_cache: {},
|
|||
send_threads: [], postLog: [],
|
||||
person_cache: {}, cached_webfingers: {},
|
||||
debug: bool, project_version: str,
|
||||
signing_priv_key_pem: str) -> {}:
|
||||
signing_priv_key_pem: str,
|
||||
curr_domain: str, onion_domain: str, i2p_domain: str) -> {}:
|
||||
"""Likes a given status post. This is only used by unit tests
|
||||
"""
|
||||
like_domain = get_full_domain(like_domain, like_port)
|
||||
|
@ -170,7 +174,8 @@ def like_post(recent_posts_cache: {},
|
|||
cc_list, http_prefix, object_url, actor_liked,
|
||||
client_to_server,
|
||||
send_threads, postLog, person_cache, cached_webfingers,
|
||||
debug, project_version, signing_priv_key_pem)
|
||||
debug, project_version, signing_priv_key_pem,
|
||||
curr_domain, onion_domain, i2p_domain)
|
||||
|
||||
|
||||
def send_like_via_server(base_dir: str, session,
|
||||
|
|
|
@ -251,7 +251,10 @@ def manual_approve_follow_request(session, session_onion, session_i2p,
|
|||
person_cache,
|
||||
debug,
|
||||
project_version, False,
|
||||
signing_priv_key_pem)
|
||||
signing_priv_key_pem,
|
||||
domain,
|
||||
onion_domain,
|
||||
i2p_domain)
|
||||
update_approved_followers = True
|
||||
else:
|
||||
# this isn't the approved follow so it will remain
|
||||
|
|
23
posts.py
23
posts.py
|
@ -2723,7 +2723,8 @@ def send_signed_json(post_json_object: {}, session, base_dir: str,
|
|||
person_cache: {}, debug: bool, project_version: str,
|
||||
shared_items_token: str, group_account: bool,
|
||||
signing_priv_key_pem: str,
|
||||
source_id: int) -> int:
|
||||
source_id: int, curr_domain: str,
|
||||
onion_domain: str, i2p_domain: str) -> int:
|
||||
"""Sends a signed json object to an inbox/outbox
|
||||
"""
|
||||
if debug:
|
||||
|
@ -2819,12 +2820,19 @@ def send_signed_json(post_json_object: {}, session, base_dir: str,
|
|||
# shared_inbox is optional
|
||||
|
||||
# get the senders private key
|
||||
account_domain = origin_domain
|
||||
if onion_domain:
|
||||
if account_domain == onion_domain:
|
||||
account_domain = curr_domain
|
||||
if i2p_domain:
|
||||
if account_domain == i2p_domain:
|
||||
account_domain = curr_domain
|
||||
private_key_pem = \
|
||||
_get_person_key(nickname, domain, base_dir, 'private', debug)
|
||||
_get_person_key(nickname, account_domain, base_dir, 'private', debug)
|
||||
if len(private_key_pem) == 0:
|
||||
if debug:
|
||||
print('DEBUG: Private key not found for ' +
|
||||
nickname + '@' + domain +
|
||||
nickname + '@' + account_domain +
|
||||
' in ' + base_dir + '/keys/private')
|
||||
return 6
|
||||
|
||||
|
@ -3143,7 +3151,8 @@ def _send_to_named_addresses(session, session_onion, session_i2p,
|
|||
send_threads, post_log, cached_webfingers,
|
||||
person_cache, debug, project_version,
|
||||
shared_items_token, group_account,
|
||||
signing_priv_key_pem, 34436782)
|
||||
signing_priv_key_pem, 34436782,
|
||||
domain, onion_domain, i2p_domain)
|
||||
|
||||
|
||||
def send_to_named_addresses_thread(session, session_onion, session_i2p,
|
||||
|
@ -3368,7 +3377,8 @@ def send_to_followers(session, session_onion, session_i2p,
|
|||
send_threads, post_log, cached_webfingers,
|
||||
person_cache, debug, project_version,
|
||||
shared_items_token, group_account,
|
||||
signing_priv_key_pem, 639342)
|
||||
signing_priv_key_pem, 639342,
|
||||
domain, onion_domain, i2p_domain)
|
||||
else:
|
||||
# send to individual followers without using a shared inbox
|
||||
for handle in follower_handles:
|
||||
|
@ -3397,7 +3407,8 @@ def send_to_followers(session, session_onion, session_i2p,
|
|||
send_threads, post_log, cached_webfingers,
|
||||
person_cache, debug, project_version,
|
||||
shared_items_token, group_account,
|
||||
signing_priv_key_pem, 634219)
|
||||
signing_priv_key_pem, 634219,
|
||||
domain, onion_domain, i2p_domain)
|
||||
|
||||
time.sleep(4)
|
||||
|
||||
|
|
13
reaction.py
13
reaction.py
|
@ -70,7 +70,9 @@ def _reactionpost(recent_posts_cache: {},
|
|||
send_threads: [], post_log: [],
|
||||
person_cache: {}, cached_webfingers: {},
|
||||
debug: bool, project_version: str,
|
||||
signing_priv_key_pem: str) -> {}:
|
||||
signing_priv_key_pem: str,
|
||||
curr_domain: str,
|
||||
onion_domain: str, i2p_domain: str) -> {}:
|
||||
"""Creates an emoji reaction
|
||||
actor is the person doing the reacting
|
||||
'to' might be a specific person (actor) whose post was reaction
|
||||
|
@ -141,7 +143,8 @@ def _reactionpost(recent_posts_cache: {},
|
|||
send_threads, post_log, cached_webfingers,
|
||||
person_cache,
|
||||
debug, project_version, None, group_account,
|
||||
signing_priv_key_pem, 7165392)
|
||||
signing_priv_key_pem, 7165392,
|
||||
curr_domain, onion_domain, i2p_domain)
|
||||
|
||||
return new_reaction_json
|
||||
|
||||
|
@ -156,7 +159,8 @@ def reaction_post(recent_posts_cache: {},
|
|||
send_threads: [], post_log: [],
|
||||
person_cache: {}, cached_webfingers: {},
|
||||
debug: bool, project_version: str,
|
||||
signing_priv_key_pem: str) -> {}:
|
||||
signing_priv_key_pem: str,
|
||||
curr_domain: str, onion_domain: str, i2p_domain: str) -> {}:
|
||||
"""Adds a reaction to a given status post. This is only used by unit tests
|
||||
"""
|
||||
reaction_domain = get_full_domain(reaction_domain, reaction_port)
|
||||
|
@ -172,7 +176,8 @@ def reaction_post(recent_posts_cache: {},
|
|||
actor_reaction, client_to_server,
|
||||
send_threads, post_log, person_cache,
|
||||
cached_webfingers,
|
||||
debug, project_version, signing_priv_key_pem)
|
||||
debug, project_version, signing_priv_key_pem,
|
||||
curr_domain, onion_domain, i2p_domain)
|
||||
|
||||
|
||||
def send_reaction_via_server(base_dir: str, session,
|
||||
|
|
21
tests.py
21
tests.py
|
@ -1393,7 +1393,8 @@ def test_post_message_between_servers(base_dir: str) -> None:
|
|||
'alice', alice_domain, alice_port, [],
|
||||
status_number, False, bob_send_threads, bob_post_log,
|
||||
bob_person_cache, bob_cached_webfingers,
|
||||
True, __version__, signing_priv_key_pem)
|
||||
True, __version__, signing_priv_key_pem,
|
||||
bob_domain, None, None)
|
||||
|
||||
for _ in range(20):
|
||||
if 'likes' in open(outbox_post_filename).read():
|
||||
|
@ -1415,7 +1416,8 @@ def test_post_message_between_servers(base_dir: str) -> None:
|
|||
status_number, '😀',
|
||||
False, bob_send_threads, bob_post_log,
|
||||
bob_person_cache, bob_cached_webfingers,
|
||||
True, __version__, signing_priv_key_pem)
|
||||
True, __version__, signing_priv_key_pem,
|
||||
bob_domain, None, None)
|
||||
|
||||
for i in range(20):
|
||||
if 'reactions' in open(outbox_post_filename).read():
|
||||
|
@ -1451,7 +1453,8 @@ def test_post_message_between_servers(base_dir: str) -> None:
|
|||
object_url,
|
||||
False, bob_send_threads, bob_post_log,
|
||||
bob_person_cache, bob_cached_webfingers,
|
||||
True, __version__, signing_priv_key_pem)
|
||||
True, __version__, signing_priv_key_pem,
|
||||
bob_domain, None, None)
|
||||
announce_message_arrived = False
|
||||
outbox_message_arrived = False
|
||||
for i in range(10):
|
||||
|
@ -1597,7 +1600,8 @@ def test_follow_between_servers(base_dir: str) -> None:
|
|||
client_to_server, federation_list,
|
||||
alice_send_threads, alice_post_log,
|
||||
alice_cached_webfingers, alice_person_cache,
|
||||
True, __version__, signing_priv_key_pem)
|
||||
True, __version__, signing_priv_key_pem,
|
||||
alice_domain, None, None)
|
||||
print('send_result: ' + str(send_result))
|
||||
|
||||
for _ in range(16):
|
||||
|
@ -1818,7 +1822,8 @@ def test_shared_items_federation(base_dir: str) -> None:
|
|||
client_to_server, federation_list,
|
||||
alice_send_threads, alice_post_log,
|
||||
alice_cached_webfingers, alice_person_cache,
|
||||
True, __version__, signing_priv_key_pem)
|
||||
True, __version__, signing_priv_key_pem,
|
||||
alice_domain, None, None)
|
||||
print('send_result: ' + str(send_result))
|
||||
|
||||
for _ in range(16):
|
||||
|
@ -2270,7 +2275,8 @@ def test_group_follow(base_dir: str) -> None:
|
|||
client_to_server, federation_list,
|
||||
alice_send_threads, alice_post_log,
|
||||
alice_cached_webfingers, alice_person_cache,
|
||||
True, __version__, signing_priv_key_pem)
|
||||
True, __version__, signing_priv_key_pem,
|
||||
alice_domain, None, None)
|
||||
print('send_result: ' + str(send_result))
|
||||
|
||||
alice_following_filename = \
|
||||
|
@ -2348,7 +2354,8 @@ def test_group_follow(base_dir: str) -> None:
|
|||
client_to_server, federation_list,
|
||||
bob_send_threads, bob_post_log,
|
||||
bob_cached_webfingers, bob_person_cache,
|
||||
True, __version__, signing_priv_key_pem)
|
||||
True, __version__, signing_priv_key_pem,
|
||||
bob_domain, None, None)
|
||||
print('send_result: ' + str(send_result))
|
||||
|
||||
bob_following_filename = \
|
||||
|
|
Loading…
Reference in New Issue