diff --git a/daemon.py b/daemon.py index cd615e3f9..71c27eab9 100644 --- a/daemon.py +++ b/daemon.py @@ -456,7 +456,8 @@ class PubServer(BaseHTTPRequestHandler): pass def _send_reply_to_question(self, nickname: str, message_id: str, - answer: str) -> None: + answer: str, + curr_session, proxy_type: str) -> None: """Sends a reply to a question """ votes_filename = \ @@ -518,7 +519,8 @@ class PubServer(BaseHTTPRequestHandler): # name field contains the answer message_json['object']['name'] = answer if self._post_to_outbox(message_json, - self.server.project_version, nickname): + self.server.project_version, nickname, + curr_session, proxy_type): post_filename = \ locate_post(self.server.base_dir, nickname, self.server.domain, message_id) @@ -641,20 +643,25 @@ class PubServer(BaseHTTPRequestHandler): return key_id return None - def _establish_session(self, calling_function: str) -> bool: + def _establish_session(self, + calling_function: str, + curr_session, + proxy_type: str): """Recreates session if needed """ - if self.server.session: - return True + if curr_session: + return curr_session print('DEBUG: creating new session during ' + calling_function) - self.server.session = create_session(self.server.proxy_type) - if self.server.session: - return True + curr_session = create_session(proxy_type) + if curr_session: + self.server.session = curr_session + return curr_session print('ERROR: GET failed to create session during ' + calling_function) - return False + return None - def _secure_mode(self, force: bool = False) -> bool: + def _secure_mode(self, curr_session, proxy_type: str, + force: bool = False) -> bool: """http authentication of GET requests for json """ if not self.server.secure_mode and not force: @@ -673,13 +680,16 @@ class PubServer(BaseHTTPRequestHandler): print('AUTH: Secure mode GET request not permitted: ' + key_id) return False - if not self._establish_session("secure mode"): + curr_session = \ + self._establish_session("secure mode", + curr_session, proxy_type) + if not curr_session: return False # obtain the public key pub_key = \ get_person_pub_key(self.server.base_dir, - self.server.session, key_id, + curr_session, key_id, self.server.person_cache, self.server.debug, self.server.project_version, self.server.http_prefix, @@ -1412,7 +1422,8 @@ class PubServer(BaseHTTPRequestHandler): return True def _post_to_outbox(self, message_json: {}, version: str, - post_to_nickname: str) -> bool: + post_to_nickname: str, + curr_session, proxy_type: str) -> bool: """post is received by the outbox Client to server message post https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery @@ -1430,7 +1441,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.shared_items_federated_domains shared_item_federation_tokens = \ self.server.shared_item_federation_tokens - return post_message_to_outbox(self.server.session, + return post_message_to_outbox(curr_session, self.server.translate, message_json, self.post_to_nickname, self.server, self.server.base_dir, @@ -1448,7 +1459,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.cached_webfingers, self.server.person_cache, self.server.allow_deletion, - self.server.proxy_type, version, + proxy_type, version, self.server.debug, self.server.yt_replace_domain, self.server.twitter_replacement_domain, @@ -2446,7 +2457,8 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, domain_full: str, port: int, onion_domain: str, i2p_domain: str, - debug: bool) -> None: + debug: bool, + curr_session, proxy_type: str) -> None: """Receive POST from person options screen """ page_number = 1 @@ -2803,7 +2815,8 @@ class PubServer(BaseHTTPRequestHandler): # send block activity self._send_block(http_prefix, chooser_nickname, domain_full, - options_nickname, options_domain_full) + options_nickname, options_domain_full, + curr_session, proxy_type) # person options screen, unblock button # See html_person_options @@ -2899,7 +2912,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.recent_posts_cache, self.server.max_recent_posts, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.server.port, @@ -3035,7 +3048,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.recent_posts_cache, self.server.max_recent_posts, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.server.port, @@ -3163,7 +3176,8 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, domain_full: str, port: int, onion_domain: str, i2p_domain: str, - debug: bool) -> None: + debug: bool, + curr_session, proxy_type: str) -> None: """Confirm to follow """ users_path = path.split('/followconfirm')[0] @@ -3226,7 +3240,7 @@ class PubServer(BaseHTTPRequestHandler): follower_nickname + ' to ' + following_actor) if not self.server.signing_priv_key_pem: print('Sending follow request with no signing key') - send_follow_request(self.server.session, + send_follow_request(curr_session, base_dir, follower_nickname, domain, port, http_prefix, @@ -3253,7 +3267,8 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, domain_full: str, port: int, onion_domain: str, i2p_domain: str, - debug: bool) -> None: + debug: bool, + curr_session, proxy_type: str) -> None: """Confirms a block """ users_path = path.split('/blockconfirm')[0] @@ -3328,7 +3343,8 @@ class PubServer(BaseHTTPRequestHandler): # send block activity self._send_block(http_prefix, blocker_nickname, domain_full, - blocking_nickname, blocking_domain_full) + blocking_nickname, blocking_domain_full, + curr_session, proxy_type) if calling_domain.endswith('.onion') and onion_domain: origin_path_str = 'http://' + onion_domain + users_path elif (calling_domain.endswith('.i2p') and i2p_domain): @@ -3428,7 +3444,8 @@ class PubServer(BaseHTTPRequestHandler): port: int, search_for_emoji: bool, onion_domain: str, i2p_domain: str, getreq_start_time, getreq_timings: {}, - debug: bool) -> None: + debug: bool, + curr_session, proxy_type: str) -> None: """Receive a search query """ # get the page number @@ -3494,7 +3511,7 @@ class PubServer(BaseHTTPRequestHandler): base_dir, search_str[1:], 1, MAX_POSTS_IN_HASHTAG_FEED, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, http_prefix, @@ -3595,7 +3612,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.project_version, self.server.recent_posts_cache, self.server.max_recent_posts, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, port, @@ -3668,7 +3685,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.project_version, self.server.recent_posts_cache, self.server.max_recent_posts, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, port, @@ -3706,7 +3723,11 @@ class PubServer(BaseHTTPRequestHandler): return # profile search nickname = get_nickname_from_actor(actor_str) - if not self._establish_session("handle search"): + curr_session = \ + self._establish_session("handle search", + curr_session, + proxy_type) + if not curr_session: self.server.postreq_busy = False return profile_path_str = path.replace('/searchhandle', '') @@ -3725,7 +3746,7 @@ class PubServer(BaseHTTPRequestHandler): else: actor = search_str avatar_url = \ - get_avatar_image_url(self.server.session, + get_avatar_image_url(curr_session, base_dir, http_prefix, actor, self.server.person_cache, @@ -3739,7 +3760,8 @@ class PubServer(BaseHTTPRequestHandler): domain, domain_full, getreq_start_time, onion_domain, i2p_domain, - cookie, debug, authorized) + cookie, debug, authorized, + curr_session, proxy_type) return else: show_published_date_only = \ @@ -3779,7 +3801,7 @@ class PubServer(BaseHTTPRequestHandler): domain, port, search_str, - self.server.session, + curr_session, cached_webfingers, self.server.person_cache, self.server.debug, @@ -3891,7 +3913,8 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, domain_full: str, onion_domain: str, i2p_domain: str, - debug: bool) -> None: + debug: bool, + curr_session, proxy_type: str) -> None: """Receive a vote via POST """ page_number = 1 @@ -3959,7 +3982,8 @@ class PubServer(BaseHTTPRequestHandler): if '&' in answer: answer = answer.split('&')[0] - self._send_reply_to_question(nickname, message_id, answer) + self._send_reply_to_question(nickname, message_id, answer, + curr_session, proxy_type) if calling_domain.endswith('.onion') and onion_domain: actor = 'http://' + onion_domain + users_path elif (calling_domain.endswith('.i2p') and i2p_domain): @@ -4907,7 +4931,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, debug: bool, allow_local_network_access: bool, system_language: str, - content_license_url: str) -> None: + content_license_url: str, + curr_session, proxy_type: str) -> None: """Updates your user profile after editing via the Edit button on the profile screen """ @@ -6809,7 +6834,8 @@ class PubServer(BaseHTTPRequestHandler): str(update_actor_json)) self._post_to_outbox(update_actor_json, self.server.project_version, - nickname) + nickname, + curr_session, proxy_type) # deactivate the account if fields.get('deactivateThisAccount'): @@ -7157,7 +7183,8 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, port: int, proxy_type: str, getreq_start_time, - debug: bool) -> None: + debug: bool, + curr_session) -> None: """Returns an RSS2 feed for the blog """ nickname = path.split('/blog/')[1] @@ -7166,12 +7193,16 @@ class PubServer(BaseHTTPRequestHandler): if not nickname.startswith('rss.'): account_dir = acct_dir(self.server.base_dir, nickname, domain) if os.path.isdir(account_dir): - if not self._establish_session("RSS request"): + curr_session = \ + self._establish_session("RSS request", + curr_session, + proxy_type) + if not curr_session: return msg = \ html_blog_page_rss2(authorized, - self.server.session, + curr_session, base_dir, http_prefix, self.server.translate, @@ -7205,10 +7236,15 @@ class PubServer(BaseHTTPRequestHandler): domain_full: str, port: int, proxy_type: str, translate: {}, getreq_start_time, - debug: bool) -> None: + debug: bool, + curr_session) -> None: """Returns an RSS2 feed for all blogs on this instance """ - if not self._establish_session("get_rss2site"): + curr_session = \ + self._establish_session("get_rss2site", + curr_session, + proxy_type) + if not curr_session: self._404() return @@ -7221,7 +7257,7 @@ class PubServer(BaseHTTPRequestHandler): domain = acct.split('@')[1] msg += \ html_blog_page_rss2(authorized, - self.server.session, + curr_session, base_dir, http_prefix, self.server.translate, @@ -7259,10 +7295,15 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, port: int, proxy_type: str, getreq_start_time, - debug: bool) -> None: + debug: bool, + curr_session) -> None: """Returns the newswire feed """ - if not self._establish_session("get_newswire_feed"): + curr_session = \ + self._establish_session("get_newswire_feed", + curr_session, + proxy_type) + if not curr_session: self._404() return @@ -7293,10 +7334,14 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, port: int, proxy_type: str, getreq_start_time, - debug: bool) -> None: + debug: bool, + curr_session) -> None: """Returns the hashtag categories feed """ - if not self._establish_session("get_hashtag_categories_feed"): + curr_session = \ + self._establish_session("get_hashtag_categories_feed", + curr_session, proxy_type) + if not curr_session: self._404() return @@ -7325,7 +7370,8 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, port: int, proxy_type: str, getreq_start_time, - debug: bool, system_language: str) -> None: + debug: bool, system_language: str, + curr_session) -> None: """Returns an RSS3 feed """ nickname = path.split('/blog/')[1] @@ -7334,12 +7380,15 @@ class PubServer(BaseHTTPRequestHandler): if not nickname.startswith('rss.'): account_dir = acct_dir(base_dir, nickname, domain) if os.path.isdir(account_dir): - if not self._establish_session("get_rss3feed"): + curr_session = \ + self._establish_session("get_rss3feed", + curr_session, proxy_type) + if not curr_session: self._404() return msg = \ html_blog_page_rss3(authorized, - self.server.session, + curr_session, base_dir, http_prefix, self.server.translate, nickname, domain, port, @@ -7368,7 +7417,8 @@ class PubServer(BaseHTTPRequestHandler): getreq_start_time, onion_domain: str, i2p_domain: str, cookie: str, debug: bool, - authorized: bool) -> None: + authorized: bool, + curr_session, proxy_type: str) -> None: """Show person options screen """ back_to_path = '' @@ -7446,8 +7496,8 @@ class PubServer(BaseHTTPRequestHandler): if actor_json.get('alsoKnownAs'): also_known_as = actor_json['alsoKnownAs'] - if self.server.session: - check_for_changed_actor(self.server.session, + if curr_session: + check_for_changed_actor(curr_session, self.server.base_dir, self.server.http_prefix, self.server.domain_full, @@ -7820,7 +7870,8 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, domain_full: str, port: int, onion_domain: str, i2p_domain: str, - getreq_start_time) -> None: + getreq_start_time, + curr_session, proxy_type: str) -> None: """Return the result of a hashtag search """ page_number = 1 @@ -7860,7 +7911,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, base_dir, hashtag, page_number, - MAX_POSTS_IN_HASHTAG_FEED, self.server.session, + MAX_POSTS_IN_HASHTAG_FEED, + curr_session, self.server.cached_webfingers, self.server.person_cache, http_prefix, @@ -7904,7 +7956,8 @@ class PubServer(BaseHTTPRequestHandler): base_dir: str, http_prefix: str, domain: str, domain_full: str, port: int, onion_domain: str, i2p_domain: str, - getreq_start_time) -> None: + getreq_start_time, + curr_session, proxy_type: str) -> None: """Return an RSS 2 feed for a hashtag """ hashtag = path.split('/tags/rss2/')[1] @@ -7924,7 +7977,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, base_dir, hashtag, - MAX_POSTS_IN_FEED, self.server.session, + MAX_POSTS_IN_FEED, curr_session, self.server.cached_webfingers, self.server.person_cache, http_prefix, @@ -7962,7 +8015,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, repeat_private: bool, - debug: bool) -> None: + debug: bool, + curr_session) -> None: """The announce/repeat button was pressed on a post """ page_number = 1 @@ -7999,7 +8053,10 @@ class PubServer(BaseHTTPRequestHandler): self._redirect_headers(actor_path_str, cookie, calling_domain) return - if not self._establish_session("announceButton"): + curr_session = \ + self._establish_session("announceButton", + curr_session, proxy_type) + if not curr_session: self._404() return self.server.actorRepeat = path.split('?actor=')[1] @@ -8010,7 +8067,7 @@ class PubServer(BaseHTTPRequestHandler): if not repeat_private: announce_to_str = 'https://www.w3.org/ns/activitystreams#Public' announce_json = \ - create_announce(self.server.session, + create_announce(curr_session, base_dir, self.server.federation_list, self.post_to_nickname, @@ -8043,7 +8100,8 @@ class PubServer(BaseHTTPRequestHandler): # send out the announce within a separate thread self._post_to_outbox(announce_json, self.server.project_version, - self.post_to_nickname) + self.post_to_nickname, + curr_session, proxy_type) fitness_performance(getreq_start_time, self.server.fitness, '_GET', '_announce_button postToOutboxThread', @@ -8075,7 +8133,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.post_to_nickname, domain, @@ -8117,7 +8175,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, repeat_private: bool, debug: bool, - recent_posts_cache: {}) -> None: + recent_posts_cache: {}, + curr_session) -> None: """Undo announce/repeat button was pressed """ page_number = 1 @@ -8157,7 +8216,10 @@ class PubServer(BaseHTTPRequestHandler): self._redirect_headers(actor_path_str, cookie, calling_domain) return - if not self._establish_session("undoAnnounceButton"): + curr_session = \ + self._establish_session("undoAnnounceButton", + curr_session, proxy_type) + if not curr_session: self._404() return undo_announce_actor = \ @@ -8200,7 +8262,8 @@ class PubServer(BaseHTTPRequestHandler): self._post_to_outbox(new_undo_announce, self.server.project_version, - self.post_to_nickname) + self.post_to_nickname, + curr_session, proxy_type) actor_absolute = self._get_instance_url(calling_domain) + actor actor_path_str = \ @@ -8217,7 +8280,8 @@ class PubServer(BaseHTTPRequestHandler): domain: str, domain_full: str, port: int, onion_domain: str, i2p_domain: str, getreq_start_time, - proxy_type: str, debug: bool) -> None: + proxy_type: str, debug: bool, + curr_session) -> None: """Follow approve button was pressed """ origin_path_str = path.split('/followapprove=')[0] @@ -8231,12 +8295,15 @@ class PubServer(BaseHTTPRequestHandler): handle_nickname + '@' + \ get_full_domain(handle_domain, handle_port) if '@' in following_handle: - if not self._establish_session("followApproveButton"): + curr_session = \ + self._establish_session("followApproveButton", + curr_session, proxy_type) + if not curr_session: self._404() return signing_priv_key_pem = \ self.server.signing_priv_key_pem - manual_approve_follow_request_thread(self.server.session, + manual_approve_follow_request_thread(curr_session, base_dir, http_prefix, follower_nickname, domain, port, @@ -8381,7 +8448,8 @@ class PubServer(BaseHTTPRequestHandler): domain: str, domain_full: str, port: int, onion_domain: str, i2p_domain: str, getreq_start_time, - proxy_type: str, debug: bool) -> None: + proxy_type: str, debug: bool, + curr_session) -> None: """Follow deny button was pressed """ origin_path_str = path.split('/followdeny=')[0] @@ -8395,7 +8463,7 @@ class PubServer(BaseHTTPRequestHandler): handle_nickname + '@' + \ get_full_domain(handle_domain, handle_port) if '@' in following_handle: - manual_deny_follow_request_thread(self.server.session, + manual_deny_follow_request_thread(curr_session, base_dir, http_prefix, follower_nickname, domain, port, @@ -8428,7 +8496,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> None: + debug: str, + curr_session) -> None: """Press the like button """ page_number = 1 @@ -8466,7 +8535,10 @@ class PubServer(BaseHTTPRequestHandler): self._redirect_headers(actor_path_str, cookie, calling_domain) return - if not self._establish_session("likeButton"): + curr_session = \ + self._establish_session("likeButton", + curr_session, proxy_type) + if not curr_session: self._404() return like_actor = \ @@ -8495,7 +8567,8 @@ class PubServer(BaseHTTPRequestHandler): } # send out the like to followers - self._post_to_outbox(like_json, self.server.project_version, None) + self._post_to_outbox(like_json, self.server.project_version, None, + curr_session, proxy_type) fitness_performance(getreq_start_time, self.server.fitness, '_GET', '_like_button postToOutbox', @@ -8550,7 +8623,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.post_to_nickname, domain, @@ -8600,7 +8673,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> None: + debug: str, + curr_session) -> None: """A button is pressed to undo """ page_number = 1 @@ -8637,7 +8711,10 @@ class PubServer(BaseHTTPRequestHandler): self._redirect_headers(actor_path_str, cookie, calling_domain) return - if not self._establish_session("undoLikeButton"): + curr_session = \ + self._establish_session("undoLikeButton", + curr_session, proxy_type) + if not curr_session: self._404() return undo_actor = \ @@ -8672,7 +8749,8 @@ class PubServer(BaseHTTPRequestHandler): # send out the undo like to followers self._post_to_outbox(undo_like_json, - self.server.project_version, None) + self.server.project_version, None, + curr_session, proxy_type) # directly undo the like within the post file if not liked_post_filename: @@ -8713,7 +8791,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.post_to_nickname, domain, @@ -8759,7 +8837,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> None: + debug: str, + curr_session) -> None: """Press an emoji reaction button Note that this is not the emoji reaction selection icon at the bottom of the post @@ -8813,7 +8892,10 @@ class PubServer(BaseHTTPRequestHandler): self._redirect_headers(actor_path_str, cookie, calling_domain) return - if not self._establish_session("reactionButton"): + curr_session = \ + self._establish_session("reactionButton", + curr_session, proxy_type) + if not curr_session: self._404() return reaction_actor = \ @@ -8844,7 +8926,8 @@ class PubServer(BaseHTTPRequestHandler): } # send out the emoji reaction to followers - self._post_to_outbox(reaction_json, self.server.project_version, None) + self._post_to_outbox(reaction_json, self.server.project_version, None, + curr_session, proxy_type) fitness_performance(getreq_start_time, self.server.fitness, '_GET', '_reaction_button postToOutbox', @@ -8905,7 +8988,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.post_to_nickname, domain, @@ -8953,7 +9036,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> None: + debug: str, + curr_session) -> None: """A button is pressed to undo emoji reaction """ page_number = 1 @@ -9005,7 +9089,10 @@ class PubServer(BaseHTTPRequestHandler): calling_domain) return emoji_content = urllib.parse.unquote_plus(emoji_content_encoded) - if not self._establish_session("undoReactionButton"): + curr_session = \ + self._establish_session("undoReactionButton", + curr_session, proxy_type) + if not curr_session: self._404() return undo_actor = \ @@ -9041,7 +9128,8 @@ class PubServer(BaseHTTPRequestHandler): # send out the undo emoji reaction to followers self._post_to_outbox(undo_reaction_json, - self.server.project_version, None) + self.server.project_version, None, + curr_session, proxy_type) # directly undo the emoji reaction within the post file if not reaction_post_filename: @@ -9087,7 +9175,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.post_to_nickname, domain, @@ -9131,7 +9219,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> None: + debug: str, + curr_session) -> None: """Press the emoji reaction picker icon at the bottom of the post """ page_number = 1 @@ -9193,7 +9282,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, self.server.base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.post_to_nickname, @@ -9229,7 +9318,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> None: + debug: str, + curr_session) -> None: """Bookmark button was pressed """ page_number = 1 @@ -9267,14 +9357,17 @@ class PubServer(BaseHTTPRequestHandler): self._redirect_headers(actor_path_str, cookie, calling_domain) return - if not self._establish_session("bookmarkButton"): + curr_session = \ + self._establish_session("bookmarkButton", + curr_session, proxy_type) + if not curr_session: self._404() return bookmark_actor = \ local_actor_url(http_prefix, self.post_to_nickname, domain_full) cc_list = [] bookmark_post(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, self.server.federation_list, self.post_to_nickname, @@ -9319,7 +9412,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.post_to_nickname, domain, @@ -9347,7 +9440,8 @@ class PubServer(BaseHTTPRequestHandler): else: print('WARN: Bookmarked post not found: ' + bookmark_filename) # self._post_to_outbox(bookmark_json, - # self.server.project_version, None) + # self.server.project_version, None, + # curr_session, proxy_type) actor_absolute = self._get_instance_url(calling_domain) + actor actor_path_str = \ actor_absolute + '/' + timeline_str + \ @@ -9364,7 +9458,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> None: + debug: str, + curr_session) -> None: """Button pressed to undo a bookmark """ page_number = 1 @@ -9401,14 +9496,17 @@ class PubServer(BaseHTTPRequestHandler): self._redirect_headers(actor_path_str, cookie, calling_domain) return - if not self._establish_session("undo_bookmarkButton"): + curr_session = \ + self._establish_session("undo_bookmarkButton", + curr_session, proxy_type) + if not curr_session: self._404() return undo_actor = \ local_actor_url(http_prefix, self.post_to_nickname, domain_full) cc_list = [] undo_bookmark_post(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, self.server.federation_list, self.post_to_nickname, @@ -9426,7 +9524,8 @@ class PubServer(BaseHTTPRequestHandler): if self.server.iconsCache.get('bookmark_inactive.png'): del self.server.iconsCache['bookmark_inactive.png'] # self._post_to_outbox(undo_bookmark_json, - # self.server.project_version, None) + # self.server.project_version, None, + # curr_session, proxy_type) bookmark_filename = \ locate_post(base_dir, self.post_to_nickname, domain, bookmark_url) if bookmark_filename: @@ -9455,7 +9554,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.post_to_nickname, domain, @@ -9499,7 +9598,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> None: + debug: str, + curr_session) -> None: """Delete button is pressed on a post """ if not cookie: @@ -9550,7 +9650,10 @@ class PubServer(BaseHTTPRequestHandler): self._redirect_headers(actor + '/' + timeline_str, cookie, calling_domain) return - if not self._establish_session("deleteButton"): + curr_session = \ + self._establish_session("deleteButton", + curr_session, proxy_type) + if not curr_session: self._404() return @@ -9559,7 +9662,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.recent_posts_cache, self.server.max_recent_posts, self.server.translate, page_number, - self.server.session, base_dir, + curr_session, base_dir, delete_url, http_prefix, self.server.project_version, self.server.cached_webfingers, @@ -9598,7 +9701,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str): + debug: str, + curr_session): """Mute button is pressed """ mute_url = path.split('?mute=')[1] @@ -9665,7 +9769,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, nickname, domain, @@ -9714,7 +9818,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str): + debug: str, + curr_session): """Undo mute button is pressed """ mute_url = path.split('?unmute=')[1] @@ -9781,7 +9886,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, nickname, domain, @@ -9828,7 +9933,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str, session) -> bool: + debug: str, + curr_session) -> bool: """Shows the replies to a post """ if not ('/statuses/' in path and '/users/' in path): @@ -9885,7 +9991,10 @@ class PubServer(BaseHTTPRequestHandler): } if self._request_http(): - if not self._establish_session("showRepliesToPost"): + curr_session = \ + self._establish_session("showRepliesToPost", + curr_session, proxy_type) + if not curr_session: self._404() return True recent_posts_cache = self.server.recent_posts_cache @@ -9908,7 +10017,7 @@ class PubServer(BaseHTTPRequestHandler): max_recent_posts, translate, base_dir, - session, + curr_session, cached_webfingers, person_cache, nickname, @@ -9938,7 +10047,7 @@ class PubServer(BaseHTTPRequestHandler): '_GET', '_show_replies_to_post', self.server.debug) else: - if self._secure_mode(): + if self._secure_mode(curr_session, proxy_type): msg = json.dumps(replies_json, ensure_ascii=False) msg = msg.encode('utf-8') protocol_str = 'application/json' @@ -9981,7 +10090,10 @@ class PubServer(BaseHTTPRequestHandler): # send the replies json if self._request_http(): - if not self._establish_session("showRepliesToPost2"): + curr_session = \ + self._establish_session("showRepliesToPost2", + curr_session, proxy_type) + if not curr_session: self._404() return True recent_posts_cache = self.server.recent_posts_cache @@ -10004,7 +10116,7 @@ class PubServer(BaseHTTPRequestHandler): max_recent_posts, translate, base_dir, - session, + curr_session, cached_webfingers, person_cache, nickname, @@ -10034,7 +10146,7 @@ class PubServer(BaseHTTPRequestHandler): '_GET', '_show_replies_to_post', self.server.debug) else: - if self._secure_mode(): + if self._secure_mode(curr_session, proxy_type): msg = json.dumps(replies_json, ensure_ascii=False) msg = msg.encode('utf-8') @@ -10058,7 +10170,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Show roles within profile screen """ named_status = path.split('/users/')[1] @@ -10121,7 +10234,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.project_version, base_dir, http_prefix, True, get_person, 'roles', - self.server.session, + curr_session, cached_webfingers, self.server.person_cache, yt_replace_domain, @@ -10152,7 +10265,7 @@ class PubServer(BaseHTTPRequestHandler): '_GET', '_show_roles', self.server.debug) else: - if self._secure_mode(): + if self._secure_mode(curr_session, proxy_type): roles_list = get_actor_roles_list(actor_json) msg = json.dumps(roles_list, ensure_ascii=False) @@ -10176,7 +10289,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Show skills on the profile screen """ named_status = path.split('/users/')[1] @@ -10246,7 +10360,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.project_version, base_dir, http_prefix, True, get_person, 'skills', - self.server.session, + curr_session, cached_webfingers, self.server.person_cache, yt_replace_domain, @@ -10280,7 +10394,8 @@ class PubServer(BaseHTTPRequestHandler): '_GET', '_show_skills', self.server.debug) else: - if self._secure_mode(): + if self._secure_mode(curr_session, + proxy_type): actor_skills_list = \ get_occupation_skills(actor_json) skills = \ @@ -10313,7 +10428,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """get an individual post from the path /@nickname/statusnumber """ if '/@' not in path: @@ -10369,7 +10485,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain, i2p_domain, getreq_start_time, proxy_type, cookie, debug, - include_create_wrapper) + include_create_wrapper, + curr_session) fitness_performance(getreq_start_time, self.server.fitness, '_GET', '_show_individual_at_post', self.server.debug) @@ -10382,7 +10499,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Show the likers of a post """ if not authorized: @@ -10407,7 +10525,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.access_keys, self.server.recent_posts_cache, self.server.max_recent_posts, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.server.project_version, @@ -10442,7 +10560,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Show the announcers of a post """ if not authorized: @@ -10468,7 +10587,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.access_keys, self.server.recent_posts_cache, self.server.max_recent_posts, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.server.project_version, @@ -10506,7 +10625,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str, include_create_wrapper: bool) -> bool: + debug: str, include_create_wrapper: bool, + curr_session) -> bool: """Shows an individual post from its filename """ if not os.path.isfile(post_filename): @@ -10541,7 +10661,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, base_dir, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, nickname, domain, port, @@ -10571,7 +10691,7 @@ class PubServer(BaseHTTPRequestHandler): '_GET', '_show_post_from_file', self.server.debug) else: - if self._secure_mode(): + if self._secure_mode(curr_session, proxy_type): if not include_create_wrapper and \ post_json_object['type'] == 'Create' and \ has_object_dict(post_json_object): @@ -10604,7 +10724,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows an individual post """ liked_by = None @@ -10654,7 +10775,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain, i2p_domain, getreq_start_time, proxy_type, cookie, debug, - include_create_wrapper) + include_create_wrapper, + curr_session) fitness_performance(getreq_start_time, self.server.fitness, '_GET', '_show_individual_post', self.server.debug) @@ -10667,7 +10789,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows an individual post from an account which you are following and where you have the notify checkbox set on person options """ @@ -10699,7 +10822,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain, i2p_domain, getreq_start_time, proxy_type, cookie, debug, - include_create_wrapper) + include_create_wrapper, + curr_session) fitness_performance(getreq_start_time, self.server.fitness, '_GET', '_show_notify_post', self.server.debug) @@ -10713,7 +10837,7 @@ class PubServer(BaseHTTPRequestHandler): getreq_start_time, proxy_type: str, cookie: str, debug: str, - recent_posts_cache: {}, session, + recent_posts_cache: {}, curr_session, default_timeline: str, max_recent_posts: int, translate: {}, @@ -10729,7 +10853,7 @@ class PubServer(BaseHTTPRequestHandler): if authorized: inbox_feed = \ person_box_json(recent_posts_cache, - session, + curr_session, base_dir, domain, port, @@ -10761,7 +10885,7 @@ class PubServer(BaseHTTPRequestHandler): # if no page was specified then show the first inbox_feed = \ person_box_json(recent_posts_cache, - session, + curr_session, base_dir, domain, port, @@ -10799,7 +10923,7 @@ class PubServer(BaseHTTPRequestHandler): max_recent_posts, translate, page_number, MAX_POSTS_IN_FEED, - session, + curr_session, base_dir, cached_webfingers, person_cache, @@ -10880,21 +11004,22 @@ class PubServer(BaseHTTPRequestHandler): return True return False - def _show_d_ms(self, authorized: bool, - calling_domain: str, path: str, - base_dir: str, http_prefix: str, - domain: str, domain_full: str, port: int, - onion_domain: str, i2p_domain: str, - getreq_start_time, - proxy_type: str, cookie: str, - debug: str) -> bool: + def _show_dms(self, authorized: bool, + calling_domain: str, path: str, + base_dir: str, http_prefix: str, + domain: str, domain_full: str, port: int, + onion_domain: str, i2p_domain: str, + getreq_start_time, + proxy_type: str, cookie: str, + debug: str, + curr_session) -> bool: """Shows the DMs timeline """ if '/users/' in path: if authorized: inbox_dm_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -10920,7 +11045,7 @@ class PubServer(BaseHTTPRequestHandler): # if no page was specified then show the first inbox_dm_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -10959,7 +11084,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -11000,7 +11125,7 @@ class PubServer(BaseHTTPRequestHandler): self._write(msg) fitness_performance(getreq_start_time, self.server.fitness, - '_GET', '_show_d_ms', + '_GET', '_show_dms', self.server.debug) else: # don't need authorized fetch here because @@ -11014,7 +11139,7 @@ class PubServer(BaseHTTPRequestHandler): self._write(msg) fitness_performance(getreq_start_time, self.server.fitness, - '_GET', '_show_d_ms json', + '_GET', '_show_dms json', self.server.debug) return True else: @@ -11038,15 +11163,15 @@ class PubServer(BaseHTTPRequestHandler): domain: str, domain_full: str, port: int, onion_domain: str, i2p_domain: str, getreq_start_time, - proxy_type: str, cookie: str, - debug: str) -> bool: + proxy_type: str, cookie: str, debug: str, + curr_session) -> bool: """Shows the replies timeline """ if '/users/' in path: if authorized: inbox_replies_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11073,7 +11198,7 @@ class PubServer(BaseHTTPRequestHandler): # if no page was specified then show the first inbox_replies_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11111,7 +11236,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -11191,14 +11316,15 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the media timeline """ if '/users/' in path: if authorized: inbox_media_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11225,7 +11351,7 @@ class PubServer(BaseHTTPRequestHandler): # if no page was specified then show the first inbox_media_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11260,7 +11386,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_MEDIA_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -11341,14 +11467,15 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the blogs timeline """ if '/users/' in path: if authorized: inbox_blogs_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11375,7 +11502,7 @@ class PubServer(BaseHTTPRequestHandler): # if no page was specified then show the first inbox_blogs_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11410,7 +11537,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_BLOGS_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -11492,14 +11619,15 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the news timeline """ if '/users/' in path: if authorized: inbox_news_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11529,7 +11657,7 @@ class PubServer(BaseHTTPRequestHandler): # if no page was specified then show the first inbox_news_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11568,7 +11696,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_NEWS_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -11650,14 +11778,15 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the features timeline (all local blogs) """ if '/users/' in path: if authorized: inbox_features_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11687,7 +11816,7 @@ class PubServer(BaseHTTPRequestHandler): # if no page was specified then show the first inbox_features_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -11731,7 +11860,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.translate, page_number, MAX_POSTS_IN_BLOGS_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -11812,7 +11941,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the shares timeline """ if '/users/' in path: @@ -11847,7 +11977,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -11902,7 +12032,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the wanted timeline """ if '/users/' in path: @@ -11936,7 +12067,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -11992,14 +12123,15 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the bookmarks timeline """ if '/users/' in path: if authorized: bookmarks_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -12026,7 +12158,7 @@ class PubServer(BaseHTTPRequestHandler): # if no page was specified then show the first bookmarks_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -12065,7 +12197,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -12145,13 +12277,14 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the outbox timeline """ # get outbox feed for a person outbox_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, path, http_prefix, MAX_POSTS_IN_FEED, 'outbox', authorized, @@ -12177,7 +12310,7 @@ class PubServer(BaseHTTPRequestHandler): page_str = '?page=' + str(page_number) outbox_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, path + page_str, http_prefix, @@ -12210,7 +12343,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -12253,7 +12386,7 @@ class PubServer(BaseHTTPRequestHandler): '_GET', '_show_outbox_timeline', self.server.debug) else: - if self._secure_mode(): + if self._secure_mode(curr_session, proxy_type): msg = json.dumps(outbox_feed, ensure_ascii=False) msg = msg.encode('utf-8') @@ -12277,14 +12410,15 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the moderation timeline """ if '/users/' in path: if authorized: moderation_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -12310,7 +12444,7 @@ class PubServer(BaseHTTPRequestHandler): # if no page was specified then show the first moderation_feed = \ person_box_json(self.server.recent_posts_cache, - self.server.session, + curr_session, base_dir, domain, port, @@ -12349,7 +12483,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.max_recent_posts, self.server.translate, page_number, MAX_POSTS_IN_FEED, - self.server.session, + curr_session, base_dir, self.server.cached_webfingers, self.server.person_cache, @@ -12426,7 +12560,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str, shares_file_type: str) -> bool: + debug: str, shares_file_type: str, + curr_session) -> bool: """Shows the shares feed """ shares = \ @@ -12455,7 +12590,10 @@ class PubServer(BaseHTTPRequestHandler): search_path2 = search_path.replace('/' + shares_file_type, '') get_person = person_lookup(domain, search_path2, base_dir) if get_person: - if not self._establish_session("show_shares_feed"): + curr_session = \ + self._establish_session("show_shares_feed", + curr_session, proxy_type) + if not curr_session: self._404() self.server.getreq_busy = False return True @@ -12490,7 +12628,7 @@ class PubServer(BaseHTTPRequestHandler): base_dir, http_prefix, authorized, get_person, shares_file_type, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.server.yt_replace_domain, @@ -12525,7 +12663,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.getreq_busy = False return True else: - if self._secure_mode(): + if self._secure_mode(curr_session, proxy_type): msg = json.dumps(shares, ensure_ascii=False) msg = msg.encode('utf-8') @@ -12549,7 +12687,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the following feed """ following = \ @@ -12581,7 +12720,10 @@ class PubServer(BaseHTTPRequestHandler): search_path.replace('/following', ''), base_dir) if get_person: - if not self._establish_session("show_following_feed"): + curr_session = \ + self._establish_session("show_following_feed", + curr_session, proxy_type) + if not curr_session: self._404() return True @@ -12618,7 +12760,7 @@ class PubServer(BaseHTTPRequestHandler): base_dir, http_prefix, authorized, get_person, 'following', - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.server.yt_replace_domain, @@ -12652,7 +12794,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.debug) return True else: - if self._secure_mode(): + if self._secure_mode(curr_session, proxy_type): msg = json.dumps(following, ensure_ascii=False).encode('utf-8') msglen = len(msg) @@ -12675,7 +12817,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the followers feed """ followers = \ @@ -12707,7 +12850,10 @@ class PubServer(BaseHTTPRequestHandler): search_path.replace('/followers', ''), base_dir) if get_person: - if not self._establish_session("show_followers_feed"): + curr_session = \ + self._establish_session("show_followers_feed", + curr_session, proxy_type) + if not curr_session: self._404() return True @@ -12745,7 +12891,7 @@ class PubServer(BaseHTTPRequestHandler): http_prefix, authorized, get_person, 'followers', - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.server.yt_replace_domain, @@ -12779,7 +12925,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.debug) return True else: - if self._secure_mode(): + if self._secure_mode(curr_session, proxy_type): msg = json.dumps(followers, ensure_ascii=False).encode('utf-8') msglen = len(msg) @@ -12844,7 +12990,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - debug: str) -> bool: + debug: str, + curr_session) -> bool: """Shows the profile for a person """ # look up a person @@ -12852,7 +12999,10 @@ class PubServer(BaseHTTPRequestHandler): if not actor_json: return False if self._request_http(): - if not self._establish_session("showPersonProfile"): + curr_session = \ + self._establish_session("showPersonProfile", + curr_session, proxy_type) + if not curr_session: self._404() return True @@ -12886,7 +13036,7 @@ class PubServer(BaseHTTPRequestHandler): http_prefix, authorized, actor_json, 'posts', - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.server.yt_replace_domain, @@ -12919,7 +13069,7 @@ class PubServer(BaseHTTPRequestHandler): if self.server.debug: print('DEBUG: html actor sent') else: - if self._secure_mode(): + if self._secure_mode(curr_session, proxy_type): accept_str = self.headers['Accept'] msg_str = json.dumps(actor_json, ensure_ascii=False) msg = msg_str.encode('utf-8') @@ -13029,7 +13179,8 @@ class PubServer(BaseHTTPRequestHandler): onion_domain: str, i2p_domain: str, getreq_start_time, proxy_type: str, cookie: str, - translate: {}, debug: str) -> bool: + translate: {}, debug: str, + curr_session) -> bool: """Shows a blog page """ page_number = 1 @@ -13050,12 +13201,15 @@ class PubServer(BaseHTTPRequestHandler): page_number = 1 elif page_number > 10: page_number = 10 - if not self._establish_session("showBlogPage"): + curr_session = \ + self._establish_session("showBlogPage", + curr_session, proxy_type) + if not curr_session: self._404() self.server.getreq_busy = False return True msg = html_blog_page(authorized, - self.server.session, + curr_session, base_dir, http_prefix, translate, @@ -13601,7 +13755,8 @@ class PubServer(BaseHTTPRequestHandler): reply_category: str, domain: str, domain_full: str, getreq_start_time, cookie, - no_drop_down: bool, conversation_id: str) -> bool: + no_drop_down: bool, conversation_id: str, + curr_session, proxy_type: str) -> bool: """Shows the new post screen """ is_new_post_endpoint = False @@ -13660,7 +13815,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.recent_posts_cache, self.server.max_recent_posts, - self.server.session, + curr_session, self.server.cached_webfingers, self.server.person_cache, self.server.port, @@ -13901,7 +14056,8 @@ class PubServer(BaseHTTPRequestHandler): def _send_block(self, http_prefix: str, blocker_nickname: str, blocker_domain_full: str, - blocking_nickname: str, blocking_domain_full: str) -> bool: + blocking_nickname: str, blocking_domain_full: str, + curr_session, proxy_type: str) -> bool: if blocker_domain_full == blocking_domain_full: if blocker_nickname == blocking_nickname: # don't block self @@ -13923,7 +14079,8 @@ class PubServer(BaseHTTPRequestHandler): 'cc': [cc_url] } self._post_to_outbox(block_json, self.server.project_version, - blocker_nickname) + blocker_nickname, + curr_session, proxy_type) return True def _get_referer_domain(self, ua_str: str) -> str: @@ -13972,6 +14129,8 @@ class PubServer(BaseHTTPRequestHandler): return False def do_GET(self): + curr_session = self.server.session + proxy_type = self.server.proxy_type calling_domain = self.server.domain_full if self.headers.get('Host'): @@ -14109,7 +14268,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, + proxy_type, None, self.server.debug, self.server.enable_shared_inbox): return @@ -14419,7 +14578,10 @@ class PubServer(BaseHTTPRequestHandler): '_GET', '_masto_api[calling_domain]', self.server.debug) - if not self._establish_session("GET"): + curr_session = \ + self._establish_session("GET", curr_session, + proxy_type) + if not curr_session: self._404() fitness_performance(getreq_start_time, self.server.fitness, '_GET', 'session fail', @@ -14520,9 +14682,10 @@ class PubServer(BaseHTTPRequestHandler): self.server.http_prefix, self.server.domain, self.server.port, - self.server.proxy_type, + proxy_type, getreq_start_time, - self.server.debug) + self.server.debug, + curr_session) return if self.path == '/newswire.xml': @@ -14532,9 +14695,10 @@ class PubServer(BaseHTTPRequestHandler): self.server.http_prefix, self.server.domain, self.server.port, - self.server.proxy_type, + proxy_type, getreq_start_time, - self.server.debug) + self.server.debug, + curr_session) return # RSS 2.0 @@ -14547,9 +14711,10 @@ class PubServer(BaseHTTPRequestHandler): self.server.http_prefix, self.server.domain, self.server.port, - self.server.proxy_type, + proxy_type, getreq_start_time, - self.server.debug) + self.server.debug, + curr_session) else: self._get_rss2site(authorized, calling_domain, self.path, @@ -14557,10 +14722,11 @@ class PubServer(BaseHTTPRequestHandler): self.server.http_prefix, self.server.domain_full, self.server.port, - self.server.proxy_type, + proxy_type, self.server.translate, getreq_start_time, - self.server.debug) + self.server.debug, + curr_session) return fitness_performance(getreq_start_time, self.server.fitness, @@ -14576,10 +14742,11 @@ class PubServer(BaseHTTPRequestHandler): self.server.http_prefix, self.server.domain, self.server.port, - self.server.proxy_type, + proxy_type, getreq_start_time, self.server.debug, - self.server.system_language) + self.server.system_language, + curr_session) return users_in_path = False @@ -14795,11 +14962,15 @@ class PubServer(BaseHTTPRequestHandler): self.path == '/blogs' or self.path == '/blogs/'): if '/rss.xml' not in self.path: - if not self._establish_session("show the main blog page"): + curr_session = \ + self._establish_session("show the main blog page", + curr_session, + proxy_type) + if not curr_session: self._404() return msg = html_blog_view(authorized, - self.server.session, + curr_session, self.server.base_dir, self.server.http_prefix, self.server.translate, @@ -14841,9 +15012,10 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, + proxy_type, cookie, self.server.translate, - self.server.debug): + self.server.debug, + curr_session): return # list of registered devices for e2ee @@ -14886,7 +15058,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, cookie, self.server.debug, - authorized) + authorized, + curr_session, + proxy_type) return fitness_performance(getreq_start_time, self.server.fitness, @@ -14902,7 +15076,7 @@ class PubServer(BaseHTTPRequestHandler): if blog_filename and nickname: post_json_object = load_json(blog_filename) if is_blog_post(post_json_object): - msg = html_blog_post(self.server.session, + msg = html_blog_post(curr_session, authorized, self.server.base_dir, self.server.http_prefix, @@ -15812,7 +15986,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.port, self.server.onion_domain, self.server.i2p_domain, - getreq_start_time) + getreq_start_time, + curr_session, + proxy_type) self.server.getreq_busy = False return self._hashtag_search(calling_domain, @@ -15824,7 +16000,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.port, self.server.onion_domain, self.server.i2p_domain, - getreq_start_time) + getreq_start_time, + curr_session, + proxy_type) self.server.getreq_busy = False return @@ -16037,7 +16215,7 @@ class PubServer(BaseHTTPRequestHandler): if authorized and html_getreq and '?repeat=' in self.path: self._announce_button(calling_domain, self.path, self.server.base_dir, - cookie, self.server.proxy_type, + cookie, proxy_type, self.server.http_prefix, self.server.domain, self.server.domain_full, @@ -16046,7 +16224,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.i2p_domain, getreq_start_time, repeat_private, - self.server.debug) + self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16061,7 +16240,7 @@ class PubServer(BaseHTTPRequestHandler): if authorized and html_getreq and '?unrepeat=' in self.path: self._undo_announce_button(calling_domain, self.path, self.server.base_dir, - cookie, self.server.proxy_type, + cookie, proxy_type, self.server.http_prefix, self.server.domain, self.server.domain_full, @@ -16071,7 +16250,8 @@ class PubServer(BaseHTTPRequestHandler): getreq_start_time, repeat_private, self.server.debug, - self.server.recent_posts_cache) + self.server.recent_posts_cache, + curr_session) self.server.getreq_busy = False return @@ -16092,7 +16272,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, + proxy_type, self.server.debug, self.server.newswire) self.server.getreq_busy = False @@ -16111,7 +16291,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, + proxy_type, self.server.debug, self.server.newswire) self.server.getreq_busy = False @@ -16130,8 +16310,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - self.server.debug) + proxy_type, + self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16152,8 +16333,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - self.server.debug) + proxy_type, + self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16171,9 +16353,10 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, + proxy_type, cookie, - self.server.debug) + self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16191,8 +16374,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug) + proxy_type, + cookie, self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16212,9 +16396,10 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, + proxy_type, cookie, - self.server.debug) + self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16234,8 +16419,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug) + proxy_type, + cookie, self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16254,8 +16440,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug) + proxy_type, + cookie, self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16274,8 +16461,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug) + proxy_type, + cookie, self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16294,8 +16482,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, cookie, - self.server.debug) + proxy_type, cookie, + self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16314,8 +16503,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, cookie, - self.server.debug) + proxy_type, cookie, + self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16334,8 +16524,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, cookie, - self.server.debug) + proxy_type, cookie, + self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16354,8 +16545,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, cookie, - self.server.debug) + proxy_type, cookie, + self.server.debug, + curr_session) self.server.getreq_busy = False return @@ -16570,7 +16762,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.domain, self.server.domain_full, getreq_start_time, - cookie, no_drop_down, conversation_id): + cookie, no_drop_down, conversation_id, + curr_session, proxy_type): self.server.getreq_busy = False return @@ -16589,8 +16782,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16605,8 +16799,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16621,8 +16816,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16642,9 +16838,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, cookie, + proxy_type, cookie, self.server.debug, - self.server.session): + curr_session): self.server.getreq_busy = False return @@ -16664,8 +16860,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16685,8 +16882,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16705,8 +16903,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16723,8 +16922,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16744,10 +16944,10 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, + proxy_type, cookie, self.server.debug, self.server.recent_posts_cache, - self.server.session, + curr_session, self.server.default_timeline, self.server.max_recent_posts, self.server.translate, @@ -16766,18 +16966,19 @@ class PubServer(BaseHTTPRequestHandler): # get the direct messages timeline for a given person if self.path.endswith('/dm') or '/dm?page=' in self.path: - if self._show_d_ms(authorized, - calling_domain, self.path, - self.server.base_dir, - self.server.http_prefix, - self.server.domain, - self.server.domain_full, - self.server.port, - self.server.onion_domain, - self.server.i2p_domain, - getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + if self._show_dms(authorized, + calling_domain, self.path, + self.server.base_dir, + self.server.http_prefix, + self.server.domain, + self.server.domain_full, + self.server.port, + self.server.onion_domain, + self.server.i2p_domain, + getreq_start_time, + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16797,8 +16998,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16818,8 +17020,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16839,8 +17042,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16860,8 +17064,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16878,8 +17083,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16899,8 +17105,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -16916,8 +17123,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -17016,8 +17224,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -17038,8 +17247,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -17060,8 +17270,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -17079,8 +17290,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug, 'shares'): + proxy_type, + cookie, self.server.debug, 'shares', + curr_session): self.server.getreq_busy = False return @@ -17098,8 +17310,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -17117,8 +17330,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -17137,8 +17351,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, getreq_start_time, - self.server.proxy_type, - cookie, self.server.debug): + proxy_type, + cookie, self.server.debug, + curr_session): self.server.getreq_busy = False return @@ -17155,7 +17370,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.getreq_busy = False return - if not self._secure_mode(): + if not self._secure_mode(curr_session, + proxy_type): if self.server.debug: print('WARN: Unauthorized GET') self._404() @@ -17400,7 +17616,8 @@ class PubServer(BaseHTTPRequestHandler): length: int, post_bytes, boundary: str, calling_domain: str, cookie: str, authorized: bool, - content_license_url: str) -> int: + content_license_url: str, + curr_session, proxy_type: str) -> int: # Note: this needs to happen synchronously # 0=this is not a new post # 1=new post success @@ -17633,7 +17850,8 @@ class PubServer(BaseHTTPRequestHandler): return 1 if self._post_to_outbox(message_json, self.server.project_version, - nickname): + nickname, + curr_session, proxy_type): populate_replies(self.server.base_dir, self.server.http_prefix, self.server.domain_full, @@ -17716,7 +17934,8 @@ class PubServer(BaseHTTPRequestHandler): return 1 if self._post_to_outbox(message_json, self.server.project_version, - nickname): + nickname, + curr_session, proxy_type): refresh_newswire(self.server.base_dir) populate_replies(self.server.base_dir, self.server.http_prefix, @@ -17771,7 +17990,7 @@ class PubServer(BaseHTTPRequestHandler): tags.append(tag) # get list of tags fields['message'] = \ - replace_emoji_from_tags(self.server.session, + replace_emoji_from_tags(curr_session, self.server.base_dir, fields['message'], tags, 'content', @@ -17877,7 +18096,8 @@ class PubServer(BaseHTTPRequestHandler): return 1 if self._post_to_outbox(message_json, self.server.project_version, - nickname): + nickname, + curr_session, proxy_type): populate_replies(self.server.base_dir, self.server.http_prefix, self.server.domain, @@ -17937,7 +18157,8 @@ class PubServer(BaseHTTPRequestHandler): return 1 if self._post_to_outbox(message_json, self.server.project_version, - nickname): + nickname, + curr_session, proxy_type): populate_replies(self.server.base_dir, self.server.http_prefix, self.server.domain, @@ -18012,7 +18233,8 @@ class PubServer(BaseHTTPRequestHandler): str(message_json['object']['to'])) if self._post_to_outbox(message_json, self.server.project_version, - nickname): + nickname, + curr_session, proxy_type): populate_replies(self.server.base_dir, self.server.http_prefix, self.server.domain, @@ -18076,7 +18298,8 @@ class PubServer(BaseHTTPRequestHandler): str(message_json['object']['to'])) if self._post_to_outbox(message_json, self.server.project_version, - nickname): + nickname, + curr_session, proxy_type): return 1 return -1 elif post_type == 'newreport': @@ -18115,7 +18338,8 @@ class PubServer(BaseHTTPRequestHandler): if message_json: if self._post_to_outbox(message_json, self.server.project_version, - nickname): + nickname, + curr_session, proxy_type): return 1 return -1 elif post_type == 'newquestion': @@ -18165,7 +18389,8 @@ class PubServer(BaseHTTPRequestHandler): print('DEBUG: new Question') if self._post_to_outbox(message_json, self.server.project_version, - nickname): + nickname, + curr_session, proxy_type): return 1 return -1 elif post_type == 'newshare' or post_type == 'newwanted': @@ -18247,7 +18472,8 @@ class PubServer(BaseHTTPRequestHandler): def _receive_new_post(self, post_type: str, path: str, calling_domain: str, cookie: str, authorized: bool, - content_license_url: str) -> int: + content_license_url: str, + curr_session, proxy_type: str) -> int: """A new post has been created This creates a thread to send the new post """ @@ -18351,7 +18577,8 @@ class PubServer(BaseHTTPRequestHandler): post_bytes, boundary, calling_domain, cookie, authorized, - content_license_url) + content_license_url, + curr_session, proxy_type) return page_number def _crypto_ap_iread_handle(self): @@ -18512,9 +18739,14 @@ class PubServer(BaseHTTPRequestHandler): self._400() def do_POST(self): + curr_session = self.server.session + proxy_type = self.server.proxy_type postreq_start_time = time.time() - if not self._establish_session("POST"): + curr_session = \ + self._establish_session("POST", curr_session, + proxy_type) + if not curr_session: fitness_performance(postreq_start_time, self.server.fitness, '_POST', 'create_session', self.server.debug) @@ -18667,7 +18899,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.i2p_domain, self.server.debug, self.server.allow_local_network_access, self.server.system_language, - self.server.content_license_url) + self.server.content_license_url, + curr_session, + proxy_type) self.server.postreq_busy = False return @@ -18776,7 +19010,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.onion_domain, self.server.i2p_domain, postreq_start_time, {}, - self.server.debug) + self.server.debug, + curr_session, + proxy_type) self.server.postreq_busy = False return @@ -18803,7 +19039,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.domain_full, self.server.onion_domain, self.server.i2p_domain, - self.server.debug) + self.server.debug, + curr_session, + proxy_type) self.server.postreq_busy = False return @@ -18875,7 +19113,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.port, self.server.onion_domain, self.server.i2p_domain, - self.server.debug) + self.server.debug, + curr_session, + proxy_type) self.server.postreq_busy = False return @@ -18932,7 +19172,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.port, self.server.onion_domain, self.server.i2p_domain, - self.server.debug) + self.server.debug, + curr_session, + proxy_type) self.server.postreq_busy = False return @@ -18952,7 +19194,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.port, self.server.onion_domain, self.server.i2p_domain, - self.server.debug) + self.server.debug, + curr_session, + proxy_type) self.server.postreq_busy = False return @@ -19085,7 +19329,8 @@ class PubServer(BaseHTTPRequestHandler): self._receive_new_post(curr_post_type, self.path, calling_domain, cookie, authorized, - self.server.content_license_url) + self.server.content_license_url, + curr_session, proxy_type) if page_number: print(curr_post_type + ' post received') nickname = self.path.split('/users/')[1] @@ -19295,7 +19540,8 @@ class PubServer(BaseHTTPRequestHandler): # https://www.w3.org/TR/activitypub/#object-without-create if self.outbox_authenticated: if self._post_to_outbox(message_json, - self.server.project_version, None): + self.server.project_version, None, + curr_session, proxy_type): if message_json.get('id'): locn_str = remove_id_ending(message_json['id']) self.headers['Location'] = locn_str