mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-23 18:15:53 +03:00
remove extraneous exception logging
This commit is contained in:
parent
7ca638c761
commit
fd8fb32bdd
2 changed files with 34 additions and 18 deletions
|
@ -114,38 +114,54 @@ class Keyring(object):
|
||||||
server_name. The deferreds run their callbacks in the sentinel
|
server_name. The deferreds run their callbacks in the sentinel
|
||||||
logcontext.
|
logcontext.
|
||||||
"""
|
"""
|
||||||
|
# a list of VerifyKeyRequests
|
||||||
verify_requests = []
|
verify_requests = []
|
||||||
|
handle = preserve_fn(_handle_key_deferred)
|
||||||
|
|
||||||
for server_name, json_object in server_and_json:
|
def process(server_name, json_object):
|
||||||
|
"""Process an entry in the request list
|
||||||
|
|
||||||
|
Given a (server_name, json_object) pair from the request list,
|
||||||
|
adds a key request to verify_requests, and returns a deferred which will
|
||||||
|
complete or fail (in the sentinel context) when verification completes.
|
||||||
|
"""
|
||||||
key_ids = signature_ids(json_object, server_name)
|
key_ids = signature_ids(json_object, server_name)
|
||||||
|
|
||||||
if not key_ids:
|
if not key_ids:
|
||||||
deferred = defer.fail(SynapseError(
|
return defer.fail(
|
||||||
400,
|
SynapseError(
|
||||||
"Not signed by %s" % (server_name, ),
|
400,
|
||||||
Codes.UNAUTHORIZED,
|
"Not signed by %s" % (server_name,),
|
||||||
))
|
Codes.UNAUTHORIZED,
|
||||||
else:
|
)
|
||||||
deferred = defer.Deferred()
|
)
|
||||||
|
|
||||||
logger.debug("Verifying for %s with key_ids %s",
|
logger.debug("Verifying for %s with key_ids %s",
|
||||||
server_name, key_ids)
|
server_name, key_ids)
|
||||||
|
|
||||||
|
# add the key request to the queue, but don't start it off yet.
|
||||||
verify_request = VerifyKeyRequest(
|
verify_request = VerifyKeyRequest(
|
||||||
server_name, key_ids, json_object, deferred
|
server_name, key_ids, json_object, defer.Deferred(),
|
||||||
)
|
)
|
||||||
|
|
||||||
verify_requests.append(verify_request)
|
verify_requests.append(verify_request)
|
||||||
|
|
||||||
run_in_background(self._start_key_lookups, verify_requests)
|
# now run _handle_key_deferred, which will wait for the key request
|
||||||
|
# to complete and then do the verification.
|
||||||
|
#
|
||||||
|
# We want _handle_key_request to log to the right context, so we
|
||||||
|
# wrap it with preserve_fn (aka run_in_background)
|
||||||
|
return handle(verify_request)
|
||||||
|
|
||||||
# Pass those keys to handle_key_deferred so that the json object
|
results = [
|
||||||
# signatures can be verified
|
process(server_name, json_object)
|
||||||
handle = preserve_fn(_handle_key_deferred)
|
for server_name, json_object in server_and_json
|
||||||
return [
|
|
||||||
handle(rq) for rq in verify_requests
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if verify_requests:
|
||||||
|
run_in_background(self._start_key_lookups, verify_requests)
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _start_key_lookups(self, verify_requests):
|
def _start_key_lookups(self, verify_requests):
|
||||||
"""Sets off the key fetches for each verify request
|
"""Sets off the key fetches for each verify request
|
||||||
|
|
|
@ -274,7 +274,7 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
|
||||||
"event id %s: unable to verify signature for sender %s: %s",
|
"event id %s: unable to verify signature for sender %s: %s",
|
||||||
pdu_to_check.pdu.event_id,
|
pdu_to_check.pdu.event_id,
|
||||||
pdu_to_check.sender_domain,
|
pdu_to_check.sender_domain,
|
||||||
e,
|
e.getErrorMessage(),
|
||||||
)
|
)
|
||||||
return e
|
return e
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"event id %s: unable to verify signature for event id domain: %s",
|
"event id %s: unable to verify signature for event id domain: %s",
|
||||||
pdu_to_check.pdu.event_id,
|
pdu_to_check.pdu.event_id,
|
||||||
e,
|
e.getErrorMessage(),
|
||||||
)
|
)
|
||||||
return e
|
return e
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue