summaryrefslogtreecommitdiff
path: root/synapse/config/server.py
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2019-08-15 17:30:45 +0200
committerAndrej Shadura <andrewsh@debian.org>2019-08-15 17:30:45 +0200
commitdf31d372bad705a18c7c05fc174c760289731a8b (patch)
tree6d5b3e56d90718190b5022f762fbbe8602deb843 /synapse/config/server.py
parent510a9ebe26ed04c0a834f0b3ba2057896fc3aedb (diff)
New upstream version 1.3.0
Diffstat (limited to 'synapse/config/server.py')
-rw-r--r--synapse/config/server.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/synapse/config/server.py b/synapse/config/server.py
index 00170f13..15449695 100644
--- a/synapse/config/server.py
+++ b/synapse/config/server.py
@@ -18,6 +18,7 @@
import logging
import os.path
+import attr
from netaddr import IPSet
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
@@ -38,6 +39,12 @@ DEFAULT_BIND_ADDRESSES = ["::", "0.0.0.0"]
DEFAULT_ROOM_VERSION = "4"
+ROOM_COMPLEXITY_TOO_GREAT = (
+ "Your homeserver is unable to join rooms this large or complex. "
+ "Please speak to your server administrator, or upgrade your instance "
+ "to join this room."
+)
+
class ServerConfig(Config):
def read_config(self, config, **kwargs):
@@ -247,6 +254,23 @@ class ServerConfig(Config):
self.gc_thresholds = read_gc_thresholds(config.get("gc_thresholds", None))
+ @attr.s
+ class LimitRemoteRoomsConfig(object):
+ enabled = attr.ib(
+ validator=attr.validators.instance_of(bool), default=False
+ )
+ complexity = attr.ib(
+ validator=attr.validators.instance_of((int, float)), default=1.0
+ )
+ complexity_error = attr.ib(
+ validator=attr.validators.instance_of(str),
+ default=ROOM_COMPLEXITY_TOO_GREAT,
+ )
+
+ self.limit_remote_rooms = LimitRemoteRoomsConfig(
+ **config.get("limit_remote_rooms", {})
+ )
+
bind_port = config.get("bind_port")
if bind_port:
if config.get("no_tls", False):
@@ -617,6 +641,23 @@ class ServerConfig(Config):
# Used by phonehome stats to group together related servers.
#server_context: context
+ # Resource-constrained Homeserver Settings
+ #
+ # If limit_remote_rooms.enabled is True, the room complexity will be
+ # checked before a user joins a new remote room. If it is above
+ # limit_remote_rooms.complexity, it will disallow joining or
+ # instantly leave.
+ #
+ # limit_remote_rooms.complexity_error can be set to customise the text
+ # displayed to the user when a room above the complexity threshold has
+ # its join cancelled.
+ #
+ # Uncomment the below lines to enable:
+ #limit_remote_rooms:
+ # enabled: True
+ # complexity: 1.0
+ # complexity_error: "This room is too complex."
+
# Whether to require a user to be in the room to add an alias to it.
# Defaults to 'true'.
#