From ca24fa326513c4076ac4b7524954f0639283d5fa Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 11 Mar 2022 22:59:15 +0000 Subject: [PATCH] Send follow requests using the appropriate session --- daemon.py | 23 ++++++++++++++++++++--- follow.py | 7 ++++--- tests.py | 12 ++++++++---- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/daemon.py b/daemon.py index cd28df4da..51b94cdf2 100644 --- a/daemon.py +++ b/daemon.py @@ -3275,14 +3275,31 @@ class PubServer(BaseHTTPRequestHandler): follower_nickname + ' to ' + following_actor) if not self.server.signing_priv_key_pem: print('Sending follow request with no signing key') + + curr_domain = domain + curr_port = port + curr_http_prefix = http_prefix + if onion_domain: + if following_domain.endswith('.onion'): + curr_session = self.server.session_onion + curr_domain = onion_domain + curr_port = 80 + curr_http_prefix = 'http' + if i2p_domain: + if following_domain.endswith('.i2p'): + curr_session = self.server.session_i2p + curr_domain = i2p_domain + curr_port = 80 + curr_http_prefix = 'http' + send_follow_request(curr_session, base_dir, follower_nickname, - domain, port, - http_prefix, + domain, curr_domain, curr_port, + curr_http_prefix, following_nickname, following_domain, following_actor, - following_port, http_prefix, + following_port, curr_http_prefix, False, self.server.federation_list, self.server.send_threads, self.server.postLog, diff --git a/follow.py b/follow.py index 0d632184f..3349e3b0b 100644 --- a/follow.py +++ b/follow.py @@ -852,7 +852,8 @@ def followed_account_rejects(session, base_dir: str, http_prefix: str, def send_follow_request(session, base_dir: str, - nickname: str, domain: str, port: int, + nickname: str, domain: str, + sender_domain: str, sender_port: int, http_prefix: str, follow_nickname: str, follow_domain: str, followedActor: str, @@ -870,7 +871,7 @@ def send_follow_request(session, base_dir: str, print('You are not permitted to follow the domain ' + follow_domain) return None - full_domain = get_full_domain(domain, port) + full_domain = get_full_domain(sender_domain, sender_port) follow_actor = local_actor_url(http_prefix, nickname, full_domain) request_domain = get_full_domain(follow_domain, followPort) @@ -934,7 +935,7 @@ def send_follow_request(session, base_dir: str, follow_handle, debug) send_signed_json(new_follow_json, session, base_dir, - nickname, domain, port, + nickname, sender_domain, sender_port, follow_nickname, follow_domain, followPort, 'https://www.w3.org/ns/activitystreams#Public', http_prefix, True, client_to_server, diff --git a/tests.py b/tests.py index f4121d76a..d5bed8eb3 100644 --- a/tests.py +++ b/tests.py @@ -1590,7 +1590,8 @@ def test_follow_between_servers(base_dir: str) -> None: signing_priv_key_pem = None send_result = \ send_follow_request(session_alice, alice_dir, - 'alice', alice_domain, alice_port, http_prefix, + 'alice', alice_domain, + alice_domain, alice_port, http_prefix, 'bob', bob_domain, bob_actor, bob_port, http_prefix, client_to_server, federation_list, @@ -1810,7 +1811,8 @@ def test_shared_items_federation(base_dir: str) -> None: bob_actor = http_prefix + '://' + bob_address + '/users/bob' send_result = \ send_follow_request(session_alice, alice_dir, - 'alice', alice_domain, alice_port, http_prefix, + 'alice', alice_domain, + alice_domain, alice_port, http_prefix, 'bob', bob_domain, bob_actor, bob_port, http_prefix, client_to_server, federation_list, @@ -2261,7 +2263,8 @@ def test_group_follow(base_dir: str) -> None: signing_priv_key_pem = None send_result = \ send_follow_request(session_alice, alice_dir, - 'alice', alice_domain, alice_port, http_prefix, + 'alice', alice_domain, + alice_domain, alice_port, http_prefix, 'testgroup', testgroup_domain, testgroup_actor, testgroupPort, http_prefix, client_to_server, federation_list, @@ -2338,7 +2341,8 @@ def test_group_follow(base_dir: str) -> None: signing_priv_key_pem = None send_result = \ send_follow_request(session_bob, bob_dir, - 'bob', bob_domain, bob_port, http_prefix, + 'bob', bob_domain, + bob_domain, bob_port, http_prefix, 'testgroup', testgroup_domain, testgroup_actor, testgroupPort, http_prefix, client_to_server, federation_list,