Correctly handle all the places that can throw exceptions
This commit is contained in:
parent
92d850fc87
commit
963256638d
|
@ -97,8 +97,11 @@ def lookup(destination, path):
|
||||||
if ":" in destination:
|
if ":" in destination:
|
||||||
return "https://%s%s" % (destination, path)
|
return "https://%s%s" % (destination, path)
|
||||||
else:
|
else:
|
||||||
srv = srvlookup.lookup("matrix", "tcp", destination)[0]
|
try:
|
||||||
return "https://%s:%d%s" % (srv.host, srv.port, path)
|
srv = srvlookup.lookup("matrix", "tcp", destination)[0]
|
||||||
|
return "https://%s:%d%s" % (srv.host, srv.port, path)
|
||||||
|
except:
|
||||||
|
return "https://%s:%d%s" % (destination, 8448, path)
|
||||||
|
|
||||||
def get_json(origin_name, origin_key, destination, path):
|
def get_json(origin_name, origin_key, destination, path):
|
||||||
request_json = {
|
request_json = {
|
||||||
|
|
|
@ -61,7 +61,8 @@ class FederationBase(object):
|
||||||
# Check local db.
|
# Check local db.
|
||||||
new_pdu = yield self.store.get_event(
|
new_pdu = yield self.store.get_event(
|
||||||
pdu.event_id,
|
pdu.event_id,
|
||||||
allow_rejected=True
|
allow_rejected=True,
|
||||||
|
allow_none=True,
|
||||||
)
|
)
|
||||||
if new_pdu:
|
if new_pdu:
|
||||||
signed_pdus.append(new_pdu)
|
signed_pdus.append(new_pdu)
|
||||||
|
@ -69,15 +70,18 @@ class FederationBase(object):
|
||||||
|
|
||||||
# Check pdu.origin
|
# Check pdu.origin
|
||||||
if pdu.origin != origin:
|
if pdu.origin != origin:
|
||||||
new_pdu = yield self.get_pdu(
|
try:
|
||||||
destinations=[pdu.origin],
|
new_pdu = yield self.get_pdu(
|
||||||
event_id=pdu.event_id,
|
destinations=[pdu.origin],
|
||||||
outlier=outlier,
|
event_id=pdu.event_id,
|
||||||
)
|
outlier=outlier,
|
||||||
|
)
|
||||||
|
|
||||||
if new_pdu:
|
if new_pdu:
|
||||||
signed_pdus.append(new_pdu)
|
signed_pdus.append(new_pdu)
|
||||||
continue
|
continue
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
logger.warn("Failed to find copy of %s with valid signature")
|
logger.warn("Failed to find copy of %s with valid signature")
|
||||||
|
|
||||||
|
|
|
@ -411,9 +411,12 @@ class FederationServer(FederationBase):
|
||||||
"_handle_new_pdu getting state for %s",
|
"_handle_new_pdu getting state for %s",
|
||||||
pdu.room_id
|
pdu.room_id
|
||||||
)
|
)
|
||||||
state, auth_chain = yield self.get_state_for_room(
|
try:
|
||||||
origin, pdu.room_id, pdu.event_id,
|
state, auth_chain = yield self.get_state_for_room(
|
||||||
)
|
origin, pdu.room_id, pdu.event_id,
|
||||||
|
)
|
||||||
|
except:
|
||||||
|
logger.warn("Failed to get state for event: %s", pdu.event_id)
|
||||||
|
|
||||||
ret = yield self.handler.on_receive_pdu(
|
ret = yield self.handler.on_receive_pdu(
|
||||||
origin,
|
origin,
|
||||||
|
|
|
@ -788,6 +788,18 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
defer.returnValue(ret)
|
defer.returnValue(ret)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def trigger_query_auth(self, destination, event_id):
|
||||||
|
local_auth_chain = yield self.store.get_auth_chain([event_id])
|
||||||
|
|
||||||
|
result = yield self.replication_layer.query_auth(
|
||||||
|
destination,
|
||||||
|
event.room_id,
|
||||||
|
event.event_id,
|
||||||
|
local_auth_chain,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
@log_function
|
@log_function
|
||||||
def do_auth(self, origin, event, context, auth_events):
|
def do_auth(self, origin, event, context, auth_events):
|
||||||
|
|
Loading…
Reference in New Issue