mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Merge branch 'master' of github.com:matrix-org/synapse into develop
This commit is contained in:
commit
74626a8de4
@ -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:
|
||||||
|
try:
|
||||||
srv = srvlookup.lookup("matrix", "tcp", destination)[0]
|
srv = srvlookup.lookup("matrix", "tcp", destination)[0]
|
||||||
return "https://%s:%d%s" % (srv.host, srv.port, path)
|
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 = {
|
||||||
|
@ -50,8 +50,11 @@ class FederationBase(object):
|
|||||||
Returns:
|
Returns:
|
||||||
Deferred : A list of PDUs that have valid signatures and hashes.
|
Deferred : A list of PDUs that have valid signatures and hashes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
signed_pdus = []
|
signed_pdus = []
|
||||||
for pdu in pdus:
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def do(pdu):
|
||||||
try:
|
try:
|
||||||
new_pdu = yield self._check_sigs_and_hash(pdu)
|
new_pdu = yield self._check_sigs_and_hash(pdu)
|
||||||
signed_pdus.append(new_pdu)
|
signed_pdus.append(new_pdu)
|
||||||
@ -61,14 +64,16 @@ 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)
|
||||||
continue
|
return
|
||||||
|
|
||||||
# Check pdu.origin
|
# Check pdu.origin
|
||||||
if pdu.origin != origin:
|
if pdu.origin != origin:
|
||||||
|
try:
|
||||||
new_pdu = yield self.get_pdu(
|
new_pdu = yield self.get_pdu(
|
||||||
destinations=[pdu.origin],
|
destinations=[pdu.origin],
|
||||||
event_id=pdu.event_id,
|
event_id=pdu.event_id,
|
||||||
@ -77,9 +82,19 @@ class FederationBase(object):
|
|||||||
|
|
||||||
if new_pdu:
|
if new_pdu:
|
||||||
signed_pdus.append(new_pdu)
|
signed_pdus.append(new_pdu)
|
||||||
continue
|
return
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
logger.warn("Failed to find copy of %s with valid signature")
|
logger.warn(
|
||||||
|
"Failed to find copy of %s with valid signature",
|
||||||
|
pdu.event_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
yield defer.gatherResults(
|
||||||
|
[do(pdu) for pdu in pdus],
|
||||||
|
consumeErrors=True
|
||||||
|
)
|
||||||
|
|
||||||
defer.returnValue(signed_pdus)
|
defer.returnValue(signed_pdus)
|
||||||
|
|
||||||
|
@ -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
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
state, auth_chain = yield self.get_state_for_room(
|
state, auth_chain = yield self.get_state_for_room(
|
||||||
origin, pdu.room_id, pdu.event_id,
|
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,
|
||||||
|
Loading…
Reference in New Issue
Block a user