summary refs log tree commit diff
path: root/synapse/config/server.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--synapse/config/server.py107
1 files changed, 22 insertions, 85 deletions
diff --git a/synapse/config/server.py b/synapse/config/server.py

index fd52c0475c..0844475b15 100644 --- a/synapse/config/server.py +++ b/synapse/config/server.py
@@ -2,7 +2,7 @@ # This file is licensed under the Affero General Public License (AGPL) version 3. # # Copyright 2014-2021 The Matrix.org Foundation C.I.C. -# Copyright (C) 2023 New Vector, Ltd +# Copyright (C) 2023-2024 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -43,12 +43,6 @@ from ._util import validate_config logger = logging.Logger(__name__) -DIRECT_TCP_ERROR = """ -Using direct TCP replication for workers is no longer supported. - -Please see https://element-hq.github.io/synapse/latest/upgrade.html#direct-tcp-replication-is-no-longer-supported-migrate-to-redis -""" - # by default, we attempt to listen on both '::' *and* '0.0.0.0' because some OSes # (Windows, macOS, other BSD/Linux where net.ipv6.bindv6only is set) will only listen # on IPv6 when '::' is set. @@ -166,13 +160,6 @@ ROOM_COMPLEXITY_TOO_GREAT = ( "to join this room." ) -METRICS_PORT_WARNING = """\ -The metrics_port configuration option is deprecated in Synapse 0.31 in favour of -a listener. Please see -https://element-hq.github.io/synapse/latest/metrics-howto.html -on how to configure the new listener. ---------------------------------------------------------------------------------""" - KNOWN_LISTENER_TYPES = { "http", @@ -215,9 +202,6 @@ class HttpListenerConfig: additional_resources: Dict[str, dict] = attr.Factory(dict) tag: Optional[str] = None request_id_header: Optional[str] = None - # If true, the listener will return CORS response headers compatible with MSC3886: - # https://github.com/matrix-org/matrix-spec-proposals/pull/3886 - experimental_cors_msc3886: bool = False @attr.s(slots=True, frozen=True, auto_attribs=True) @@ -335,8 +319,14 @@ class ServerConfig(Config): logger.info("Using default public_baseurl %s", public_baseurl) else: self.serve_client_wellknown = True + # Ensure that public_baseurl ends with a trailing slash if public_baseurl[-1] != "/": public_baseurl += "/" + + # Scrutinize user-provided config + if not isinstance(public_baseurl, str): + raise ConfigError("Must be a string", ("public_baseurl",)) + self.public_baseurl = public_baseurl # check that public_baseurl is valid @@ -367,11 +357,6 @@ class ServerConfig(Config): "m.homeserver is not supported in extra_well_known_content, " "use public_baseurl in base config instead." ) - if "m.identity_server" in self.extra_well_known_client_content: - raise ConfigError( - "m.identity_server is not supported in extra_well_known_content, " - "use default_identity_server in base config instead." - ) # Whether to enable user presence. presence_config = config.get("presence") or {} @@ -479,10 +464,6 @@ class ServerConfig(Config): self.max_mau_value = config.get("max_mau_value", 0) self.mau_stats_only = config.get("mau_stats_only", False) - self.mau_limits_reserved_threepids = config.get( - "mau_limit_reserved_threepids", [] - ) - self.mau_trial_days = config.get("mau_trial_days", 0) self.mau_appservice_trial_days = config.get("mau_appservice_trial_days", {}) self.mau_limit_alerting = config.get("mau_limit_alerting", True) @@ -700,21 +681,6 @@ class ServerConfig(Config): pub_key=manhole_pub_key, ) - metrics_port = config.get("metrics_port") - if metrics_port: - logger.warning(METRICS_PORT_WARNING) - - self.listeners.append( - TCPListenerConfig( - port=metrics_port, - bind_addresses=[config.get("metrics_bind_host", "127.0.0.1")], - type="http", - http_options=HttpListenerConfig( - resources=[HttpResourceConfig(names=["metrics"])] - ), - ) - ) - self.cleanup_extremities_with_dummy_events = config.get( "cleanup_extremities_with_dummy_events", True ) @@ -724,18 +690,6 @@ class ServerConfig(Config): self.enable_ephemeral_messages = config.get("enable_ephemeral_messages", False) - # Inhibits the /requestToken endpoints from returning an error that might leak - # information about whether an e-mail address is in use or not on this - # homeserver, and instead return a 200 with a fake sid if this kind of error is - # met, without sending anything. - # This is a compromise between sending an email, which could be a spam vector, - # and letting the client know which email address is bound to an account and - # which one isn't. - self.request_token_inhibit_3pid_errors = config.get( - "request_token_inhibit_3pid_errors", - False, - ) - # Whitelist of domain names that given next_link parameters must have next_link_domain_whitelist: Optional[List[str]] = config.get( "next_link_domain_whitelist" @@ -780,6 +734,17 @@ class ServerConfig(Config): else: self.delete_stale_devices_after = None + # The maximum allowed delay duration for delayed events (MSC4140). + max_event_delay_duration = config.get("max_event_delay_duration") + if max_event_delay_duration is not None: + self.max_event_delay_ms: Optional[int] = self.parse_duration( + max_event_delay_duration + ) + if self.max_event_delay_ms <= 0: + raise ConfigError("max_event_delay_duration must be a positive value") + else: + self.max_event_delay_ms = None + def has_tls_listener(self) -> bool: return any(listener.is_tls() for listener in self.listeners) @@ -828,13 +793,10 @@ class ServerConfig(Config): ).lstrip() if not unsecure_listeners: - unsecure_http_bindings = ( - """- port: %(unsecure_port)s + unsecure_http_bindings = """- port: %(unsecure_port)s tls: false type: http - x_forwarded: true""" - % locals() - ) + x_forwarded: true""" % locals() if not open_private_ports: unsecure_http_bindings += ( @@ -853,16 +815,13 @@ class ServerConfig(Config): if not secure_listeners: secure_http_bindings = "" - return ( - """\ + return """\ server_name: "%(server_name)s" pid_file: %(pid_file)s listeners: %(secure_http_bindings)s %(unsecure_http_bindings)s - """ - % locals() - ) + """ % locals() def read_arguments(self, args: argparse.Namespace) -> None: if args.manhole is not None: @@ -915,24 +874,6 @@ class ServerConfig(Config): ) -def is_threepid_reserved( - reserved_threepids: List[JsonDict], threepid: JsonDict -) -> bool: - """Check the threepid against the reserved threepid config - Args: - reserved_threepids: List of reserved threepids - threepid: The threepid to test for - - Returns: - Is the threepid undertest reserved_user - """ - - for tp in reserved_threepids: - if threepid["medium"] == tp["medium"] and threepid["address"] == tp["address"]: - return True - return False - - def read_gc_thresholds( thresholds: Optional[List[Any]], ) -> Optional[Tuple[int, int, int]]: @@ -956,9 +897,6 @@ def parse_listener_def(num: int, listener: Any) -> ListenerConfig: raise ConfigError("Expected a dictionary", ("listeners", str(num))) listener_type = listener["type"] - # Raise a helpful error if direct TCP replication is still configured. - if listener_type == "replication": - raise ConfigError(DIRECT_TCP_ERROR, ("listeners", str(num), "type")) port = listener.get("port") socket_path = listener.get("path") @@ -999,7 +937,6 @@ def parse_listener_def(num: int, listener: Any) -> ListenerConfig: additional_resources=listener.get("additional_resources", {}), tag=listener.get("tag"), request_id_header=listener.get("request_id_header"), - experimental_cors_msc3886=listener.get("experimental_cors_msc3886", False), ) if socket_path: