您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

54 行
2.0 KiB

  1. # Copyright 2020 The Matrix.org Foundation C.I.C.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import Any, Optional
  15. from synapse.config._base import Config
  16. from synapse.config._util import validate_config
  17. from synapse.types import JsonDict
  18. class FederationConfig(Config):
  19. section = "federation"
  20. def read_config(self, config: JsonDict, **kwargs: Any) -> None:
  21. # FIXME: federation_domain_whitelist needs sytests
  22. self.federation_domain_whitelist: Optional[dict] = None
  23. federation_domain_whitelist = config.get("federation_domain_whitelist", None)
  24. if federation_domain_whitelist is not None:
  25. # turn the whitelist into a hash for speed of lookup
  26. self.federation_domain_whitelist = {}
  27. for domain in federation_domain_whitelist:
  28. self.federation_domain_whitelist[domain] = True
  29. federation_metrics_domains = config.get("federation_metrics_domains") or []
  30. validate_config(
  31. _METRICS_FOR_DOMAINS_SCHEMA,
  32. federation_metrics_domains,
  33. ("federation_metrics_domains",),
  34. )
  35. self.federation_metrics_domains = set(federation_metrics_domains)
  36. self.allow_profile_lookup_over_federation = config.get(
  37. "allow_profile_lookup_over_federation", True
  38. )
  39. self.allow_device_name_lookup_over_federation = config.get(
  40. "allow_device_name_lookup_over_federation", False
  41. )
  42. _METRICS_FOR_DOMAINS_SCHEMA = {"type": "array", "items": {"type": "string"}}