Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit bb7fdd8

Browse files
authored
Use direct references for configuration variables (part 5). (#10897)
1 parent 85551b7 commit bb7fdd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+128
-113
lines changed

changelog.d/10897.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use direct references to config flags.

synapse/app/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def start_worker_reactor(appname, config, run_command=reactor.run):
8888
appname,
8989
soft_file_limit=config.soft_file_limit,
9090
gc_thresholds=config.gc_thresholds,
91-
pid_file=config.worker_pid_file,
92-
daemonize=config.worker_daemonize,
91+
pid_file=config.worker.worker_pid_file,
92+
daemonize=config.worker.worker_daemonize,
9393
print_pidfile=config.print_pidfile,
9494
logger=logger,
9595
run_command=run_command,

synapse/app/admin_cmd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ def start(config_options):
186186
config.worker.worker_app = "synapse.app.admin_cmd"
187187

188188
if (
189-
not config.worker_daemonize
190-
and not config.worker_log_file
191-
and not config.worker_log_config
189+
not config.worker.worker_daemonize
190+
and not config.worker.worker_log_file
191+
and not config.worker.worker_log_config
192192
):
193193
# Since we're meant to be run as a "command" let's not redirect stdio
194194
# unless we've actually set log config.

synapse/app/generic_worker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(self, hs):
140140
self.auth = hs.get_auth()
141141
self.store = hs.get_datastore()
142142
self.http_client = hs.get_simple_http_client()
143-
self.main_uri = hs.config.worker_main_http_uri
143+
self.main_uri = hs.config.worker.worker_main_http_uri
144144

145145
async def on_POST(self, request: Request, device_id: Optional[str]):
146146
requester = await self.auth.get_user_by_req(request, allow_guest=True)
@@ -321,7 +321,7 @@ def _listen_http(self, listener_config: ListenerConfig):
321321
elif name == "federation":
322322
resources.update({FEDERATION_PREFIX: TransportLayerServer(self)})
323323
elif name == "media":
324-
if self.config.can_load_media_repo:
324+
if self.config.media.can_load_media_repo:
325325
media_repo = self.get_media_repository_resource()
326326

327327
# We need to serve the admin servlets for media on the
@@ -384,7 +384,7 @@ def _listen_http(self, listener_config: ListenerConfig):
384384
logger.info("Synapse worker now listening on port %d", port)
385385

386386
def start_listening(self):
387-
for listener in self.config.worker_listeners:
387+
for listener in self.config.worker.worker_listeners:
388388
if listener.type == "http":
389389
self._listen_http(listener)
390390
elif listener.type == "manhole":

synapse/app/homeserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def _configure_named_resource(self, name, compress=False):
234234
)
235235

236236
if name in ["media", "federation", "client"]:
237-
if self.config.enable_media_repo:
237+
if self.config.media.enable_media_repo:
238238
media_repo = self.get_media_repository_resource()
239239
resources.update(
240240
{MEDIA_PREFIX: media_repo, LEGACY_MEDIA_PREFIX: media_repo}

synapse/config/logger.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ def setup_logging(
322322
323323
"""
324324
log_config_path = (
325-
config.worker_log_config if use_worker_options else config.logging.log_config
325+
config.worker.worker_log_config
326+
if use_worker_options
327+
else config.logging.log_config
326328
)
327329

328330
# Perform one-time logging configuration.

synapse/crypto/context_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def configure_context(context, config):
7474
context.set_options(
7575
SSL.OP_NO_SSLv2 | SSL.OP_NO_SSLv3 | SSL.OP_NO_TLSv1 | SSL.OP_NO_TLSv1_1
7676
)
77-
context.use_certificate_chain_file(config.tls_certificate_file)
78-
context.use_privatekey(config.tls_private_key)
77+
context.use_certificate_chain_file(config.tls.tls_certificate_file)
78+
context.use_privatekey(config.tls.tls_private_key)
7979

8080
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
8181
context.set_cipher_list(

synapse/events/spamcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def load_legacy_spam_checkers(hs: "synapse.server.HomeServer"):
7878
"""
7979
spam_checkers: List[Any] = []
8080
api = hs.get_module_api()
81-
for module, config in hs.config.spam_checkers:
81+
for module, config in hs.config.spamchecker.spam_checkers:
8282
# Older spam checkers don't accept the `api` argument, so we
8383
# try and detect support.
8484
spam_args = inspect.getfullargspec(module)

synapse/events/third_party_rules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def load_legacy_third_party_event_rules(hs: "HomeServer"):
4242
"""Wrapper that loads a third party event rules module configured using the old
4343
configuration, and registers the hooks they implement.
4444
"""
45-
if hs.config.third_party_event_rules is None:
45+
if hs.config.thirdpartyrules.third_party_event_rules is None:
4646
return
4747

48-
module, config = hs.config.third_party_event_rules
48+
module, config = hs.config.thirdpartyrules.third_party_event_rules
4949

5050
api = hs.get_module_api()
5151
third_party_rules = module(config=config, module_api=api)

synapse/handlers/auth.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,23 +277,25 @@ def __init__(self, hs: "HomeServer"):
277277
# after the SSO completes and before redirecting them back to their client.
278278
# It notifies the user they are about to give access to their matrix account
279279
# to the client.
280-
self._sso_redirect_confirm_template = hs.config.sso_redirect_confirm_template
280+
self._sso_redirect_confirm_template = (
281+
hs.config.sso.sso_redirect_confirm_template
282+
)
281283

282284
# The following template is shown during user interactive authentication
283285
# in the fallback auth scenario. It notifies the user that they are
284286
# authenticating for an operation to occur on their account.
285-
self._sso_auth_confirm_template = hs.config.sso_auth_confirm_template
287+
self._sso_auth_confirm_template = hs.config.sso.sso_auth_confirm_template
286288

287289
# The following template is shown during the SSO authentication process if
288290
# the account is deactivated.
289291
self._sso_account_deactivated_template = (
290-
hs.config.sso_account_deactivated_template
292+
hs.config.sso.sso_account_deactivated_template
291293
)
292294

293295
self._server_name = hs.config.server.server_name
294296

295297
# cast to tuple for use with str.startswith
296-
self._whitelisted_sso_clients = tuple(hs.config.sso_client_whitelist)
298+
self._whitelisted_sso_clients = tuple(hs.config.sso.sso_client_whitelist)
297299

298300
# A mapping of user ID to extra attributes to include in the login
299301
# response.

0 commit comments

Comments
 (0)