diff --git a/src/admin/debug/commands.rs b/src/admin/debug/commands.rs index e1102d4ed..ad99e6805 100644 --- a/src/admin/debug/commands.rs +++ b/src/admin/debug/commands.rs @@ -1014,7 +1014,7 @@ pub(super) async fn resolve_true_destination( let resolver: &MatrixResolver = if no_cache { &MatrixResolverBuilder::new() .dangerous_tls_accept_invalid_certs(self.services.server.config.allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure) - .http_client(self.services.client.default.clone()) + .http_client(self.services.client.dns.clone()) .build()? } else { &self.services.client.matrix_resolver diff --git a/src/admin/federation/commands.rs b/src/admin/federation/commands.rs index 64a8e0dac..7f54a1d22 100644 --- a/src/admin/federation/commands.rs +++ b/src/admin/federation/commands.rs @@ -54,7 +54,7 @@ pub(super) async fn fetch_support_well_known(&self, server_name: OwnedServerName let response = self .services .client - .default + .external_resource .get(format!("https://{server_name}/.well-known/matrix/support")) .send() .await?; diff --git a/src/service/announcements/mod.rs b/src/service/announcements/mod.rs index fd0bced63..006176ac3 100644 --- a/src/service/announcements/mod.rs +++ b/src/service/announcements/mod.rs @@ -134,7 +134,7 @@ async fn check(&self) -> Result<()> { let response = self .services .client - .default + .external_resource .get(CHECK_FOR_ANNOUNCEMENTS_URL) .send() .await? diff --git a/src/service/client/mod.rs b/src/service/client/mod.rs index 8dab3856c..0fe55b0d5 100644 --- a/src/service/client/mod.rs +++ b/src/service/client/mod.rs @@ -16,9 +16,9 @@ pub struct Service { pub matrix_resolver: Arc, pub dns_resolver: Arc, - pub default: reqwest::Client, + pub dns: reqwest::Client, pub url_preview: reqwest::Client, - pub extern_media: reqwest::Client, + pub external_resource: reqwest::Client, pub federation: reqwest::Client, pub federation_slow: reqwest::Client, pub sender: reqwest::Client, @@ -35,17 +35,17 @@ fn build(args: crate::Args<'_>) -> Result> { let dns_resolver = get_dns_resolver(args.server)?; + let dns_client = base(&args.server.config)? + .connect_timeout(Duration::from_secs(args.server.config.well_known_conn_timeout)) + .read_timeout(Duration::from_secs(args.server.config.well_known_timeout)) + .timeout(Duration::from_secs(args.server.config.well_known_timeout)) + .pool_max_idle_per_host(0) + .redirect(redirect::Policy::limited(4)) + .build()?; + let matrix_resolver = Arc::new(MatrixResolverBuilder::new() .dangerous_tls_accept_invalid_certs(args.server.config.allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure) - .http_client( - base(&args.server.config)? - .connect_timeout(Duration::from_secs(args.server.config.well_known_conn_timeout)) - .read_timeout(Duration::from_secs(args.server.config.well_known_timeout)) - .timeout(Duration::from_secs(args.server.config.well_known_timeout)) - .pool_max_idle_per_host(0) - .redirect(redirect::Policy::limited(4)) - .build()? - ) + .http_client(dns_client.clone()) .dns_resolver(dns_resolver.clone()) .build()?); let matrix_dns_resolver = matrix_resolver.create_dns_resolver(); @@ -69,23 +69,19 @@ fn build(args: crate::Args<'_>) -> Result> { matrix_resolver, dns_resolver, - default: base(config)? - .dns_resolver(matrix_dns_resolver.clone()) - .build()?, + dns: dns_client, url_preview: base(config) .and_then(|builder| { builder_interface(builder, url_preview_bind_iface.as_deref()) })? .local_address(url_preview_bind_addr) - .dns_resolver(matrix_dns_resolver.clone()) .timeout(Duration::from_secs(config.url_preview_timeout)) .redirect(redirect::Policy::limited(3)) .user_agent(url_preview_user_agent) .build()?, - extern_media: base(config)? - .dns_resolver(matrix_dns_resolver.clone()) + external_resource: base(config)? .redirect(redirect::Policy::limited(3)) .build()?, @@ -128,7 +124,7 @@ fn build(args: crate::Args<'_>) -> Result> { .build()?, appservice: base(config)? - .dns_resolver(matrix_dns_resolver.clone()) + .dns_resolver(matrix_dns_resolver) .connect_timeout(Duration::from_secs(5)) .read_timeout(Duration::from_secs(config.appservice_timeout)) .timeout(Duration::from_secs(config.appservice_timeout)) @@ -138,7 +134,6 @@ fn build(args: crate::Args<'_>) -> Result> { .build()?, pusher: base(config)? - .dns_resolver(matrix_dns_resolver) .connect_timeout(Duration::from_secs(config.pusher_conn_timeout)) .timeout(Duration::from_secs(config.pusher_timeout)) .pool_max_idle_per_host(1) diff --git a/src/service/media/remote.rs b/src/service/media/remote.rs index 4a1ca828b..8db1ee69b 100644 --- a/src/service/media/remote.rs +++ b/src/service/media/remote.rs @@ -260,7 +260,7 @@ async fn location_request(&self, location: &str) -> Result { let response = self .services .client - .extern_media + .external_resource .get(location) .send() .await?;