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,
|
session, person_url, as_header, None, debug,
|
||||||
project_version, http_prefix, person_domain)
|
project_version, http_prefix, person_domain)
|
||||||
if not get_json_valid(person_json):
|
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
|
return None
|
||||||
pub_key, _ = get_actor_public_key_from_id(person_json, original_person_url)
|
pub_key, _ = get_actor_public_key_from_id(person_json, original_person_url)
|
||||||
if not pub_key:
|
if not pub_key:
|
||||||
|
|
|
@ -938,6 +938,14 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'obtain public key for ' + key_id)
|
'obtain public key for ' + key_id)
|
||||||
return False
|
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
|
# verify the GET request without any digest
|
||||||
if verify_post_headers(self.server.http_prefix,
|
if verify_post_headers(self.server.http_prefix,
|
||||||
self.server.domain_full,
|
self.server.domain_full,
|
||||||
|
|
70
inbox.py
70
inbox.py
|
@ -3142,9 +3142,16 @@ def _receive_announce(recent_posts_cache: {},
|
||||||
i2p_domain,
|
i2p_domain,
|
||||||
signing_priv_key_pem)
|
signing_priv_key_pem)
|
||||||
if pub_key:
|
if pub_key:
|
||||||
if debug:
|
if not isinstance(pub_key, dict):
|
||||||
print('DEBUG: public key obtained for announce: ' +
|
if debug:
|
||||||
lookup_actor)
|
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
|
break
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -3398,8 +3405,15 @@ def _obtain_avatar_for_reply_post(session, base_dir: str, http_prefix: str,
|
||||||
domain, onion_domain, i2p_domain,
|
domain, onion_domain, i2p_domain,
|
||||||
signing_priv_key_pem)
|
signing_priv_key_pem)
|
||||||
if pub_key:
|
if pub_key:
|
||||||
if debug:
|
if not isinstance(pub_key, dict):
|
||||||
print('DEBUG: public key obtained for reply: ' + lookup_actor)
|
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
|
break
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -5500,15 +5514,21 @@ def _receive_follow_request(session, session_onion, session_i2p,
|
||||||
# Getting their public key has the same result
|
# Getting their public key has the same result
|
||||||
if debug:
|
if debug:
|
||||||
print('Obtaining the following actor: ' + message_json['actor'])
|
print('Obtaining the following actor: ' + message_json['actor'])
|
||||||
if not get_person_pub_key(base_dir, curr_session,
|
pubkey_result = \
|
||||||
message_json['actor'],
|
get_person_pub_key(base_dir, curr_session,
|
||||||
person_cache, debug, project_version,
|
message_json['actor'],
|
||||||
curr_http_prefix,
|
person_cache, debug, project_version,
|
||||||
this_domain, onion_domain,
|
curr_http_prefix,
|
||||||
i2p_domain, signing_priv_key_pem):
|
this_domain, onion_domain,
|
||||||
|
i2p_domain, signing_priv_key_pem)
|
||||||
|
if not pubkey_result:
|
||||||
if debug:
|
if debug:
|
||||||
print('Unable to obtain following actor: ' +
|
print('Unable to obtain following actor: ' +
|
||||||
message_json['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 = \
|
group_account = \
|
||||||
has_group_type(base_dir, message_json['actor'], person_cache)
|
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:
|
if debug:
|
||||||
print('Obtaining the following actor: ' +
|
print('Obtaining the following actor: ' +
|
||||||
message_json['actor'])
|
message_json['actor'])
|
||||||
if not get_person_pub_key(base_dir, curr_session,
|
pubkey_result = \
|
||||||
message_json['actor'],
|
get_person_pub_key(base_dir, curr_session,
|
||||||
person_cache, debug, project_version,
|
message_json['actor'],
|
||||||
curr_http_prefix, this_domain,
|
person_cache, debug, project_version,
|
||||||
onion_domain, i2p_domain,
|
curr_http_prefix, this_domain,
|
||||||
signing_priv_key_pem):
|
onion_domain, i2p_domain,
|
||||||
|
signing_priv_key_pem)
|
||||||
|
if not pubkey_result:
|
||||||
if debug:
|
if debug:
|
||||||
print('Unable to obtain following actor: ' +
|
print('Unable to obtain following actor: ' +
|
||||||
message_json['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: ' +
|
print('Updating followers file: ' +
|
||||||
followers_filename + ' adding ' + approve_handle)
|
followers_filename + ' adding ' + approve_handle)
|
||||||
|
@ -5881,8 +5908,13 @@ def run_inbox_queue(server,
|
||||||
'INBOX', 'get_person_pub_key', debug)
|
'INBOX', 'get_person_pub_key', debug)
|
||||||
inbox_start_time = time.time()
|
inbox_start_time = time.time()
|
||||||
if pub_key:
|
if pub_key:
|
||||||
if debug:
|
if not isinstance(pub_key, dict):
|
||||||
print('DEBUG: public key: ' + str(pub_key))
|
if debug:
|
||||||
|
print('DEBUG: public key: ' + str(pub_key))
|
||||||
|
else:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: http code error for public key: ' +
|
||||||
|
str(pub_key))
|
||||||
break
|
break
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
|
|
Loading…
Reference in New Issue