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
d5eee5d6
Commit
d5eee5d6
authored
6 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Plain Diff
Merge commit '
33f469ba
' into release-v0.28.1
parents
d858f3bd
33f469ba
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/api/constants.py
+3
-0
3 additions, 0 deletions
synapse/api/constants.py
synapse/federation/federation_base.py
+18
-3
18 additions, 3 deletions
synapse/federation/federation_base.py
synapse/handlers/message.py
+5
-1
5 additions, 1 deletion
synapse/handlers/message.py
with
26 additions
and
4 deletions
synapse/api/constants.py
+
3
−
0
View file @
d5eee5d6
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
"""
Contains constants from the specification.
"""
"""
Contains constants from the specification.
"""
# the "depth" field on events is limited to 2**63 - 1
MAX_DEPTH
=
2
**
63
-
1
class
Membership
(
object
):
class
Membership
(
object
):
...
...
This diff is collapsed.
Click to expand it.
synapse/federation/federation_base.py
+
18
−
3
View file @
d5eee5d6
...
@@ -14,7 +14,10 @@
...
@@ -14,7 +14,10 @@
# limitations under the License.
# limitations under the License.
import
logging
import
logging
from
synapse.api.errors
import
SynapseError
import
six
from
synapse.api.constants
import
MAX_DEPTH
from
synapse.api.errors
import
SynapseError
,
Codes
from
synapse.crypto.event_signing
import
check_event_content_hash
from
synapse.crypto.event_signing
import
check_event_content_hash
from
synapse.events
import
FrozenEvent
from
synapse.events
import
FrozenEvent
from
synapse.events.utils
import
prune_event
from
synapse.events.utils
import
prune_event
...
@@ -190,11 +193,23 @@ def event_from_pdu_json(pdu_json, outlier=False):
...
@@ -190,11 +193,23 @@ def event_from_pdu_json(pdu_json, outlier=False):
FrozenEvent
FrozenEvent
Raises:
Raises:
SynapseError: if the pdu is missing required fields
SynapseError: if the pdu is missing required fields or is otherwise
not a valid matrix event
"""
"""
# we could probably enforce a bunch of other fields here (room_id, sender,
# we could probably enforce a bunch of other fields here (room_id, sender,
# origin, etc etc)
# origin, etc etc)
assert_params_in_request
(
pdu_json
,
(
'
event_id
'
,
'
type
'
))
assert_params_in_request
(
pdu_json
,
(
'
event_id
'
,
'
type
'
,
'
depth
'
))
depth
=
pdu_json
[
'
depth
'
]
if
not
isinstance
(
depth
,
six
.
integer_types
):
raise
SynapseError
(
400
,
"
Depth %r not an intger
"
%
(
depth
,
),
Codes
.
BAD_JSON
)
if
depth
<
0
:
raise
SynapseError
(
400
,
"
Depth too small
"
,
Codes
.
BAD_JSON
)
elif
depth
>
MAX_DEPTH
:
raise
SynapseError
(
400
,
"
Depth too large
"
,
Codes
.
BAD_JSON
)
event
=
FrozenEvent
(
event
=
FrozenEvent
(
pdu_json
pdu_json
)
)
...
...
This diff is collapsed.
Click to expand it.
synapse/handlers/message.py
+
5
−
1
View file @
d5eee5d6
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
from
twisted.internet
import
defer
,
reactor
from
twisted.internet
import
defer
,
reactor
from
twisted.python.failure
import
Failure
from
twisted.python.failure
import
Failure
from
synapse.api.constants
import
EventTypes
,
Membership
from
synapse.api.constants
import
EventTypes
,
Membership
,
MAX_DEPTH
from
synapse.api.errors
import
AuthError
,
Codes
,
SynapseError
from
synapse.api.errors
import
AuthError
,
Codes
,
SynapseError
from
synapse.crypto.event_signing
import
add_hashes_and_signatures
from
synapse.crypto.event_signing
import
add_hashes_and_signatures
from
synapse.events.utils
import
serialize_event
from
synapse.events.utils
import
serialize_event
...
@@ -624,6 +624,10 @@ class EventCreationHandler(object):
...
@@ -624,6 +624,10 @@ class EventCreationHandler(object):
if
prev_events_and_hashes
:
if
prev_events_and_hashes
:
depth
=
max
([
d
for
_
,
_
,
d
in
prev_events_and_hashes
])
+
1
depth
=
max
([
d
for
_
,
_
,
d
in
prev_events_and_hashes
])
+
1
# we cap depth of generated events, to ensure that they are not
# rejected by other servers (and so that they can be persisted in
# the db)
depth
=
min
(
depth
,
MAX_DEPTH
)
else
:
else
:
depth
=
1
depth
=
1
...
...
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