mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-27 05:19:21 -05:00
Use direct references for some configuration variables (part 2) (#10812)
This commit is contained in:
parent
145c006ef7
commit
8c7a531e27
1
changelog.d/10812.misc
Normal file
1
changelog.d/10812.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Use direct references to config flags.
|
@ -70,8 +70,8 @@ class Auth:
|
|||||||
|
|
||||||
self._auth_blocking = AuthBlocking(self.hs)
|
self._auth_blocking = AuthBlocking(self.hs)
|
||||||
|
|
||||||
self._track_appservice_user_ips = hs.config.track_appservice_user_ips
|
self._track_appservice_user_ips = hs.config.appservice.track_appservice_user_ips
|
||||||
self._macaroon_secret_key = hs.config.macaroon_secret_key
|
self._macaroon_secret_key = hs.config.key.macaroon_secret_key
|
||||||
self._force_tracing_for_users = hs.config.tracing.force_tracing_for_users
|
self._force_tracing_for_users = hs.config.tracing.force_tracing_for_users
|
||||||
|
|
||||||
async def check_user_in_room(
|
async def check_user_in_room(
|
||||||
|
@ -30,13 +30,15 @@ class AuthBlocking:
|
|||||||
def __init__(self, hs: "HomeServer"):
|
def __init__(self, hs: "HomeServer"):
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
|
|
||||||
self._server_notices_mxid = hs.config.server_notices_mxid
|
self._server_notices_mxid = hs.config.servernotices.server_notices_mxid
|
||||||
self._hs_disabled = hs.config.hs_disabled
|
self._hs_disabled = hs.config.server.hs_disabled
|
||||||
self._hs_disabled_message = hs.config.hs_disabled_message
|
self._hs_disabled_message = hs.config.server.hs_disabled_message
|
||||||
self._admin_contact = hs.config.admin_contact
|
self._admin_contact = hs.config.server.admin_contact
|
||||||
self._max_mau_value = hs.config.max_mau_value
|
self._max_mau_value = hs.config.server.max_mau_value
|
||||||
self._limit_usage_by_mau = hs.config.limit_usage_by_mau
|
self._limit_usage_by_mau = hs.config.server.limit_usage_by_mau
|
||||||
self._mau_limits_reserved_threepids = hs.config.mau_limits_reserved_threepids
|
self._mau_limits_reserved_threepids = (
|
||||||
|
hs.config.server.mau_limits_reserved_threepids
|
||||||
|
)
|
||||||
self._server_name = hs.hostname
|
self._server_name = hs.hostname
|
||||||
self._track_appservice_user_ips = hs.config.appservice.track_appservice_user_ips
|
self._track_appservice_user_ips = hs.config.appservice.track_appservice_user_ips
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ class FederationPolicyForHTTPS:
|
|||||||
self._config = config
|
self._config = config
|
||||||
|
|
||||||
# Check if we're using a custom list of a CA certificates
|
# Check if we're using a custom list of a CA certificates
|
||||||
trust_root = config.federation_ca_trust_root
|
trust_root = config.tls.federation_ca_trust_root
|
||||||
if trust_root is None:
|
if trust_root is None:
|
||||||
# Use CA root certs provided by OpenSSL
|
# Use CA root certs provided by OpenSSL
|
||||||
trust_root = platformTrust()
|
trust_root = platformTrust()
|
||||||
@ -113,7 +113,7 @@ class FederationPolicyForHTTPS:
|
|||||||
# moving to TLS 1.2 by default, we want to respect the config option if
|
# moving to TLS 1.2 by default, we want to respect the config option if
|
||||||
# it is set to 1.0 (which the alternate option, raiseMinimumTo, will not
|
# it is set to 1.0 (which the alternate option, raiseMinimumTo, will not
|
||||||
# let us do).
|
# let us do).
|
||||||
minTLS = _TLS_VERSION_MAP[config.federation_client_minimum_tls_version]
|
minTLS = _TLS_VERSION_MAP[config.tls.federation_client_minimum_tls_version]
|
||||||
|
|
||||||
_verify_ssl = CertificateOptions(
|
_verify_ssl = CertificateOptions(
|
||||||
trustRoot=trust_root, insecurelyLowerMinimumTo=minTLS
|
trustRoot=trust_root, insecurelyLowerMinimumTo=minTLS
|
||||||
@ -125,10 +125,10 @@ class FederationPolicyForHTTPS:
|
|||||||
self._no_verify_ssl_context = _no_verify_ssl.getContext()
|
self._no_verify_ssl_context = _no_verify_ssl.getContext()
|
||||||
self._no_verify_ssl_context.set_info_callback(_context_info_cb)
|
self._no_verify_ssl_context.set_info_callback(_context_info_cb)
|
||||||
|
|
||||||
self._should_verify = self._config.federation_verify_certificates
|
self._should_verify = self._config.tls.federation_verify_certificates
|
||||||
|
|
||||||
self._federation_certificate_verification_whitelist = (
|
self._federation_certificate_verification_whitelist = (
|
||||||
self._config.federation_certificate_verification_whitelist
|
self._config.tls.federation_certificate_verification_whitelist
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_options(self, host: bytes):
|
def get_options(self, host: bytes):
|
||||||
|
@ -572,7 +572,7 @@ class PerspectivesKeyFetcher(BaseV2KeyFetcher):
|
|||||||
super().__init__(hs)
|
super().__init__(hs)
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.client = hs.get_federation_http_client()
|
self.client = hs.get_federation_http_client()
|
||||||
self.key_servers = self.config.key_servers
|
self.key_servers = self.config.key.key_servers
|
||||||
|
|
||||||
async def _fetch_keys(
|
async def _fetch_keys(
|
||||||
self, keys_to_fetch: List[_FetchKeyRequest]
|
self, keys_to_fetch: List[_FetchKeyRequest]
|
||||||
|
@ -1237,7 +1237,7 @@ class FederationHandlerRegistry:
|
|||||||
self._edu_type_to_instance[edu_type] = instance_names
|
self._edu_type_to_instance[edu_type] = instance_names
|
||||||
|
|
||||||
async def on_edu(self, edu_type: str, origin: str, content: dict) -> None:
|
async def on_edu(self, edu_type: str, origin: str, content: dict) -> None:
|
||||||
if not self.config.use_presence and edu_type == EduTypes.Presence:
|
if not self.config.server.use_presence and edu_type == EduTypes.Presence:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check if we have a handler on this instance
|
# Check if we have a handler on this instance
|
||||||
|
@ -594,7 +594,7 @@ class FederationSender(AbstractFederationSender):
|
|||||||
destinations (list[str])
|
destinations (list[str])
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not states or not self.hs.config.use_presence:
|
if not states or not self.hs.config.server.use_presence:
|
||||||
# No-op if presence is disabled.
|
# No-op if presence is disabled.
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ class InitialSyncHandler(BaseHandler):
|
|||||||
|
|
||||||
async def get_presence():
|
async def get_presence():
|
||||||
# If presence is disabled, return an empty list
|
# If presence is disabled, return an empty list
|
||||||
if not self.hs.config.use_presence:
|
if not self.hs.config.server.use_presence:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
states = await presence_handler.get_states(
|
states = await presence_handler.get_states(
|
||||||
|
@ -374,7 +374,7 @@ class WorkerPresenceHandler(BasePresenceHandler):
|
|||||||
|
|
||||||
self._presence_writer_instance = hs.config.worker.writers.presence[0]
|
self._presence_writer_instance = hs.config.worker.writers.presence[0]
|
||||||
|
|
||||||
self._presence_enabled = hs.config.use_presence
|
self._presence_enabled = hs.config.server.use_presence
|
||||||
|
|
||||||
# Route presence EDUs to the right worker
|
# Route presence EDUs to the right worker
|
||||||
hs.get_federation_registry().register_instances_for_edu(
|
hs.get_federation_registry().register_instances_for_edu(
|
||||||
@ -584,7 +584,7 @@ class WorkerPresenceHandler(BasePresenceHandler):
|
|||||||
user_id = target_user.to_string()
|
user_id = target_user.to_string()
|
||||||
|
|
||||||
# If presence is disabled, no-op
|
# If presence is disabled, no-op
|
||||||
if not self.hs.config.use_presence:
|
if not self.hs.config.server.use_presence:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Proxy request to instance that writes presence
|
# Proxy request to instance that writes presence
|
||||||
@ -601,7 +601,7 @@ class WorkerPresenceHandler(BasePresenceHandler):
|
|||||||
with the app.
|
with the app.
|
||||||
"""
|
"""
|
||||||
# If presence is disabled, no-op
|
# If presence is disabled, no-op
|
||||||
if not self.hs.config.use_presence:
|
if not self.hs.config.server.use_presence:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Proxy request to instance that writes presence
|
# Proxy request to instance that writes presence
|
||||||
@ -618,7 +618,7 @@ class PresenceHandler(BasePresenceHandler):
|
|||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
self.wheel_timer: WheelTimer[str] = WheelTimer()
|
self.wheel_timer: WheelTimer[str] = WheelTimer()
|
||||||
self.notifier = hs.get_notifier()
|
self.notifier = hs.get_notifier()
|
||||||
self._presence_enabled = hs.config.use_presence
|
self._presence_enabled = hs.config.server.use_presence
|
||||||
|
|
||||||
federation_registry = hs.get_federation_registry()
|
federation_registry = hs.get_federation_registry()
|
||||||
|
|
||||||
@ -916,7 +916,7 @@ class PresenceHandler(BasePresenceHandler):
|
|||||||
with the app.
|
with the app.
|
||||||
"""
|
"""
|
||||||
# If presence is disabled, no-op
|
# If presence is disabled, no-op
|
||||||
if not self.hs.config.use_presence:
|
if not self.hs.config.server.use_presence:
|
||||||
return
|
return
|
||||||
|
|
||||||
user_id = user.to_string()
|
user_id = user.to_string()
|
||||||
@ -949,7 +949,7 @@ class PresenceHandler(BasePresenceHandler):
|
|||||||
"""
|
"""
|
||||||
# Override if it should affect the user's presence, if presence is
|
# Override if it should affect the user's presence, if presence is
|
||||||
# disabled.
|
# disabled.
|
||||||
if not self.hs.config.use_presence:
|
if not self.hs.config.server.use_presence:
|
||||||
affect_presence = False
|
affect_presence = False
|
||||||
|
|
||||||
if affect_presence:
|
if affect_presence:
|
||||||
|
@ -1090,7 +1090,7 @@ class SyncHandler:
|
|||||||
block_all_presence_data = (
|
block_all_presence_data = (
|
||||||
since_token is None and sync_config.filter_collection.blocks_all_presence()
|
since_token is None and sync_config.filter_collection.blocks_all_presence()
|
||||||
)
|
)
|
||||||
if self.hs_config.use_presence and not block_all_presence_data:
|
if self.hs_config.server.use_presence and not block_all_presence_data:
|
||||||
logger.debug("Fetching presence data")
|
logger.debug("Fetching presence data")
|
||||||
await self._generate_sync_entry_for_presence(
|
await self._generate_sync_entry_for_presence(
|
||||||
sync_result_builder,
|
sync_result_builder,
|
||||||
|
@ -321,8 +321,11 @@ class SimpleHttpClient:
|
|||||||
|
|
||||||
self.user_agent = hs.version_string
|
self.user_agent = hs.version_string
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
if hs.config.user_agent_suffix:
|
if hs.config.server.user_agent_suffix:
|
||||||
self.user_agent = "%s %s" % (self.user_agent, hs.config.user_agent_suffix)
|
self.user_agent = "%s %s" % (
|
||||||
|
self.user_agent,
|
||||||
|
hs.config.server.user_agent_suffix,
|
||||||
|
)
|
||||||
|
|
||||||
# We use this for our body producers to ensure that they use the correct
|
# We use this for our body producers to ensure that they use the correct
|
||||||
# reactor.
|
# reactor.
|
||||||
|
@ -365,7 +365,7 @@ class HttpPusher(Pusher):
|
|||||||
if event.type == "m.room.member" and event.is_state():
|
if event.type == "m.room.member" and event.is_state():
|
||||||
d["notification"]["membership"] = event.content["membership"]
|
d["notification"]["membership"] = event.content["membership"]
|
||||||
d["notification"]["user_is_target"] = event.state_key == self.user_id
|
d["notification"]["user_is_target"] = event.state_key == self.user_id
|
||||||
if self.hs.config.push_include_content and event.content:
|
if self.hs.config.push.push_include_content and event.content:
|
||||||
d["notification"]["content"] = event.content
|
d["notification"]["content"] = event.content
|
||||||
|
|
||||||
# We no longer send aliases separately, instead, we send the human
|
# We no longer send aliases separately, instead, we send the human
|
||||||
|
@ -110,7 +110,7 @@ class Mailer:
|
|||||||
self.state_handler = self.hs.get_state_handler()
|
self.state_handler = self.hs.get_state_handler()
|
||||||
self.storage = hs.get_storage()
|
self.storage = hs.get_storage()
|
||||||
self.app_name = app_name
|
self.app_name = app_name
|
||||||
self.email_subjects: EmailSubjectConfig = hs.config.email_subjects
|
self.email_subjects: EmailSubjectConfig = hs.config.email.email_subjects
|
||||||
|
|
||||||
logger.info("Created Mailer for app_name %s" % app_name)
|
logger.info("Created Mailer for app_name %s" % app_name)
|
||||||
|
|
||||||
@ -796,8 +796,8 @@ class Mailer:
|
|||||||
Returns:
|
Returns:
|
||||||
A link to open a room in the web client.
|
A link to open a room in the web client.
|
||||||
"""
|
"""
|
||||||
if self.hs.config.email_riot_base_url:
|
if self.hs.config.email.email_riot_base_url:
|
||||||
base_url = "%s/#/room" % (self.hs.config.email_riot_base_url)
|
base_url = "%s/#/room" % (self.hs.config.email.email_riot_base_url)
|
||||||
elif self.app_name == "Vector":
|
elif self.app_name == "Vector":
|
||||||
# need /beta for Universal Links to work on iOS
|
# need /beta for Universal Links to work on iOS
|
||||||
base_url = "https://vector.im/beta/#/room"
|
base_url = "https://vector.im/beta/#/room"
|
||||||
@ -815,9 +815,9 @@ class Mailer:
|
|||||||
Returns:
|
Returns:
|
||||||
A link to open the notification in the web client.
|
A link to open the notification in the web client.
|
||||||
"""
|
"""
|
||||||
if self.hs.config.email_riot_base_url:
|
if self.hs.config.email.email_riot_base_url:
|
||||||
return "%s/#/room/%s/%s" % (
|
return "%s/#/room/%s/%s" % (
|
||||||
self.hs.config.email_riot_base_url,
|
self.hs.config.email.email_riot_base_url,
|
||||||
notif["room_id"],
|
notif["room_id"],
|
||||||
notif["event_id"],
|
notif["event_id"],
|
||||||
)
|
)
|
||||||
|
@ -35,12 +35,12 @@ class PusherFactory:
|
|||||||
"http": HttpPusher
|
"http": HttpPusher
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("email enable notifs: %r", hs.config.email_enable_notifs)
|
logger.info("email enable notifs: %r", hs.config.email.email_enable_notifs)
|
||||||
if hs.config.email_enable_notifs:
|
if hs.config.email.email_enable_notifs:
|
||||||
self.mailers: Dict[str, Mailer] = {}
|
self.mailers: Dict[str, Mailer] = {}
|
||||||
|
|
||||||
self._notif_template_html = hs.config.email_notif_template_html
|
self._notif_template_html = hs.config.email.email_notif_template_html
|
||||||
self._notif_template_text = hs.config.email_notif_template_text
|
self._notif_template_text = hs.config.email.email_notif_template_text
|
||||||
|
|
||||||
self.pusher_types["email"] = self._create_email_pusher
|
self.pusher_types["email"] = self._create_email_pusher
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class PusherPool:
|
|||||||
self.clock = self.hs.get_clock()
|
self.clock = self.hs.get_clock()
|
||||||
|
|
||||||
# We shard the handling of push notifications by user ID.
|
# We shard the handling of push notifications by user ID.
|
||||||
self._pusher_shard_config = hs.config.push.pusher_shard_config
|
self._pusher_shard_config = hs.config.worker.pusher_shard_config
|
||||||
self._instance_name = hs.get_instance_name()
|
self._instance_name = hs.get_instance_name()
|
||||||
self._should_start_pushers = (
|
self._should_start_pushers = (
|
||||||
self._instance_name in self._pusher_shard_config.instances
|
self._instance_name in self._pusher_shard_config.instances
|
||||||
|
@ -392,7 +392,7 @@ class HomeServer(metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
@cache_in_self
|
@cache_in_self
|
||||||
def get_http_client_context_factory(self) -> IPolicyForHTTPS:
|
def get_http_client_context_factory(self) -> IPolicyForHTTPS:
|
||||||
if self.config.use_insecure_ssl_client_just_for_testing_do_not_use:
|
if self.config.tls.use_insecure_ssl_client_just_for_testing_do_not_use:
|
||||||
return InsecureInterceptableContextFactory()
|
return InsecureInterceptableContextFactory()
|
||||||
return RegularPolicyForHTTPS()
|
return RegularPolicyForHTTPS()
|
||||||
|
|
||||||
@ -418,8 +418,8 @@ class HomeServer(metaclass=abc.ABCMeta):
|
|||||||
"""
|
"""
|
||||||
return SimpleHttpClient(
|
return SimpleHttpClient(
|
||||||
self,
|
self,
|
||||||
ip_whitelist=self.config.ip_range_whitelist,
|
ip_whitelist=self.config.server.ip_range_whitelist,
|
||||||
ip_blacklist=self.config.ip_range_blacklist,
|
ip_blacklist=self.config.server.ip_range_blacklist,
|
||||||
use_proxy=True,
|
use_proxy=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -801,18 +801,18 @@ class HomeServer(metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Connecting to redis (host=%r port=%r) for external cache",
|
"Connecting to redis (host=%r port=%r) for external cache",
|
||||||
self.config.redis_host,
|
self.config.redis.redis_host,
|
||||||
self.config.redis_port,
|
self.config.redis.redis_port,
|
||||||
)
|
)
|
||||||
|
|
||||||
return lazyConnection(
|
return lazyConnection(
|
||||||
hs=self,
|
hs=self,
|
||||||
host=self.config.redis_host,
|
host=self.config.redis.redis_host,
|
||||||
port=self.config.redis_port,
|
port=self.config.redis.redis_port,
|
||||||
password=self.config.redis.redis_password,
|
password=self.config.redis.redis_password,
|
||||||
reconnect=True,
|
reconnect=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def should_send_federation(self) -> bool:
|
def should_send_federation(self) -> bool:
|
||||||
"Should this server be sending federation traffic directly?"
|
"Should this server be sending federation traffic directly?"
|
||||||
return self.config.send_federation
|
return self.config.worker.send_federation
|
||||||
|
Loading…
Reference in New Issue
Block a user