mirror of https://gitlab.com/bashrc2/epicyon
Avoid retries when certain http error codes are returned
parent
ad7bf3c033
commit
69e4775906
4
cache.py
4
cache.py
|
@ -239,6 +239,10 @@ def get_person_pub_key(base_dir: str, session, person_url: str,
|
|||
session, person_url, as_header, None, debug,
|
||||
project_version, http_prefix, person_domain)
|
||||
if not get_json_valid(person_json):
|
||||
if person_json is not None:
|
||||
if isinstance(person_json, dict):
|
||||
# return the error code
|
||||
return person_json
|
||||
return None
|
||||
pub_key, _ = get_actor_public_key_from_id(person_json, original_person_url)
|
||||
if not pub_key:
|
||||
|
|
|
@ -938,6 +938,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'obtain public key for ' + key_id)
|
||||
return False
|
||||
|
||||
# was an error http code returned?
|
||||
if isinstance(pub_key, dict):
|
||||
if self.server.debug:
|
||||
print('AUTH: failed to ' +
|
||||
'obtain public key for ' + key_id +
|
||||
' ' + str(pub_key))
|
||||
return False
|
||||
|
||||
# verify the GET request without any digest
|
||||
if verify_post_headers(self.server.http_prefix,
|
||||
self.server.domain_full,
|
||||
|
|
70
inbox.py
70
inbox.py
|
@ -3142,9 +3142,16 @@ def _receive_announce(recent_posts_cache: {},
|
|||
i2p_domain,
|
||||
signing_priv_key_pem)
|
||||
if pub_key:
|
||||
if debug:
|
||||
print('DEBUG: public key obtained for announce: ' +
|
||||
lookup_actor)
|
||||
if not isinstance(pub_key, dict):
|
||||
if debug:
|
||||
print('DEBUG: ' +
|
||||
'public key obtained for announce: ' +
|
||||
lookup_actor)
|
||||
else:
|
||||
if debug:
|
||||
print('DEBUG: http error code returned for ' +
|
||||
'public key obtained for announce: ' +
|
||||
lookup_actor + ' ' + str(pub_key))
|
||||
break
|
||||
|
||||
if debug:
|
||||
|
@ -3398,8 +3405,15 @@ def _obtain_avatar_for_reply_post(session, base_dir: str, http_prefix: str,
|
|||
domain, onion_domain, i2p_domain,
|
||||
signing_priv_key_pem)
|
||||
if pub_key:
|
||||
if debug:
|
||||
print('DEBUG: public key obtained for reply: ' + lookup_actor)
|
||||
if not isinstance(pub_key, dict):
|
||||
if debug:
|
||||
print('DEBUG: public key obtained for reply: ' +
|
||||
lookup_actor)
|
||||
else:
|
||||
if debug:
|
||||
print('DEBUG: http error code for public key ' +
|
||||
'obtained for reply: ' + lookup_actor + ' ' +
|
||||
str(pub_key))
|
||||
break
|
||||
|
||||
if debug:
|
||||
|
@ -5500,15 +5514,21 @@ def _receive_follow_request(session, session_onion, session_i2p,
|
|||
# Getting their public key has the same result
|
||||
if debug:
|
||||
print('Obtaining the following actor: ' + message_json['actor'])
|
||||
if not get_person_pub_key(base_dir, curr_session,
|
||||
message_json['actor'],
|
||||
person_cache, debug, project_version,
|
||||
curr_http_prefix,
|
||||
this_domain, onion_domain,
|
||||
i2p_domain, signing_priv_key_pem):
|
||||
pubkey_result = \
|
||||
get_person_pub_key(base_dir, curr_session,
|
||||
message_json['actor'],
|
||||
person_cache, debug, project_version,
|
||||
curr_http_prefix,
|
||||
this_domain, onion_domain,
|
||||
i2p_domain, signing_priv_key_pem)
|
||||
if not pubkey_result:
|
||||
if debug:
|
||||
print('Unable to obtain following actor: ' +
|
||||
message_json['actor'])
|
||||
elif isinstance(pubkey_result, dict):
|
||||
if debug:
|
||||
print('http error code trying to obtain following actor: ' +
|
||||
message_json['actor'] + ' ' + str(pubkey_result))
|
||||
|
||||
group_account = \
|
||||
has_group_type(base_dir, message_json['actor'], person_cache)
|
||||
|
@ -5545,15 +5565,22 @@ def _receive_follow_request(session, session_onion, session_i2p,
|
|||
if debug:
|
||||
print('Obtaining the following actor: ' +
|
||||
message_json['actor'])
|
||||
if not get_person_pub_key(base_dir, curr_session,
|
||||
message_json['actor'],
|
||||
person_cache, debug, project_version,
|
||||
curr_http_prefix, this_domain,
|
||||
onion_domain, i2p_domain,
|
||||
signing_priv_key_pem):
|
||||
pubkey_result = \
|
||||
get_person_pub_key(base_dir, curr_session,
|
||||
message_json['actor'],
|
||||
person_cache, debug, project_version,
|
||||
curr_http_prefix, this_domain,
|
||||
onion_domain, i2p_domain,
|
||||
signing_priv_key_pem)
|
||||
if not pubkey_result:
|
||||
if debug:
|
||||
print('Unable to obtain following actor: ' +
|
||||
message_json['actor'])
|
||||
elif isinstance(pubkey_result, dict):
|
||||
if debug:
|
||||
print('http error code trying to obtain ' +
|
||||
'following actor: ' + message_json['actor'] +
|
||||
' ' + str(pubkey_result))
|
||||
|
||||
print('Updating followers file: ' +
|
||||
followers_filename + ' adding ' + approve_handle)
|
||||
|
@ -5881,8 +5908,13 @@ def run_inbox_queue(server,
|
|||
'INBOX', 'get_person_pub_key', debug)
|
||||
inbox_start_time = time.time()
|
||||
if pub_key:
|
||||
if debug:
|
||||
print('DEBUG: public key: ' + str(pub_key))
|
||||
if not isinstance(pub_key, dict):
|
||||
if debug:
|
||||
print('DEBUG: public key: ' + str(pub_key))
|
||||
else:
|
||||
if debug:
|
||||
print('DEBUG: http code error for public key: ' +
|
||||
str(pub_key))
|
||||
break
|
||||
|
||||
if debug:
|
||||
|
|
Loading…
Reference in New Issue