Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
1f4b498b
Commit
1f4b498b
authored
6 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Add some comments
parent
e5852288
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/federation/federation_server.py
+23
-2
23 additions, 2 deletions
synapse/federation/federation_server.py
synapse/handlers/federation.py
+12
-3
12 additions, 3 deletions
synapse/handlers/federation.py
with
35 additions
and
5 deletions
synapse/federation/federation_server.py
+
23
−
2
View file @
1f4b498b
# -*- coding: utf-8 -*-
# Copyright 2015, 2016 OpenMarket Ltd
# Copyright 2018 New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -494,13 +495,33 @@ class FederationServer(FederationBase):
def
_handle_received_pdu
(
self
,
origin
,
pdu
):
"""
Process a PDU received in a federation /send/ transaction.
If the event is invalid, then this method throws a FederationError.
(The error will then be logged and sent back to the sender (which
probably won
'
t do anything with it), and other events in the
transaction will be processed as normal).
It is likely that we
'
ll then receive other events which refer to
this rejected_event in their prev_events, etc. When that happens,
we
'
ll attempt to fetch the rejected event again, which will presumably
fail, so those second-generation events will also get rejected.
Eventually, we get to the point where there are more than 10 events
between any new events and the original rejected event. Since we
only try to backfill 10 events deep on received pdu, we then accept the
new event, possibly introducing a discontinuity in the DAG, with new
forward extremities, so normal service is approximately returned,
until we try to backfill across the discontinuity.
Args:
origin (str): server which sent the pdu
pdu (FrozenEvent): received pdu
Returns (Deferred): completes with None
Raises: FederationError if the signatures / hash do not match
"""
Raises: FederationError if the signatures / hash do not match, or
if the event was unacceptable for any other reason (eg, too large,
too many prev_events, couldn
'
t find the prev_events)
"""
# check that it's actually being sent from a valid destination to
# workaround bug #1753 in 0.18.5 and 0.18.6
if
origin
!=
get_domain_from_id
(
pdu
.
event_id
):
...
...
This diff is collapsed.
Click to expand it.
synapse/handlers/federation.py
+
12
−
3
View file @
1f4b498b
...
...
@@ -542,9 +542,16 @@ class FederationHandler(BaseHandler):
def
backfill
(
self
,
dest
,
room_id
,
limit
,
extremities
):
"""
Trigger a backfill request to `dest` for the given `room_id`
This will attempt to get more events from the remote. This may return
be successfull and still return no events if the other side has no new
events to offer.
This will attempt to get more events from the remote. If the other side
has no new events to offer, this will return an empty list.
As the events are received, we check their signatures, and also do some
sanity-checking on them. If any of the backfilled events are invalid,
this method throws a SynapseError.
TODO: make this more useful to distinguish failures of the remote
server from invalid events (there is probably no point in trying to
re-fetch invalid events from every other HS in the room.)
"""
if
dest
==
self
.
server_name
:
raise
SynapseError
(
400
,
"
Can
'
t backfill from self.
"
)
...
...
@@ -556,6 +563,8 @@ class FederationHandler(BaseHandler):
extremities
=
extremities
,
)
# do some sanity-checking of the received events, before we go and
# do state resolution across 1000 events.
for
ev
in
events
:
self
.
_sanity_check_event
(
ev
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment