put global trust-dns resolver in an Arc

This allows us to reference it in reqwest clients configuration.
This commit is contained in:
Olivia Lee 2024-12-15 21:43:29 -08:00
parent 33f3592612
commit e98dd5b9a3
No known key found for this signature in database
GPG key ID: 54D568A15B9CD1F9

View file

@ -74,7 +74,7 @@ pub(crate) struct Service {
pub(crate) tls_name_override: Arc<StdRwLock<TlsNameMap>>,
pub(crate) config: Config,
keypair: Arc<ruma::signatures::Ed25519KeyPair>,
dns_resolver: TokioAsyncResolver,
dns_resolver: Arc<TokioAsyncResolver>,
jwt_decoding_key: Option<jsonwebtoken::DecodingKey>,
federation_client: reqwest::Client,
default_client: reqwest::Client,
@ -215,6 +215,18 @@ impl Service {
};
let tls_name_override = Arc::new(StdRwLock::new(TlsNameMap::new()));
let dns_resolver = Arc::new(
TokioAsyncResolver::tokio_from_system_conf().map_err(|e| {
error!(
"Failed to set up trust dns resolver with system config: \
{}",
e
);
Error::bad_config(
"Failed to set up trust dns resolver with system config.",
)
})?,
);
let jwt_decoding_key = config.jwt_secret.as_ref().map(|secret| {
jsonwebtoken::DecodingKey::from_secret(secret.as_bytes())
@ -255,18 +267,7 @@ impl Service {
config,
reload_handles: reload_handles.map(|h| Arc::new(RwLock::new(h))),
keypair: Arc::new(keypair),
dns_resolver: TokioAsyncResolver::tokio_from_system_conf()
.map_err(|e| {
error!(
"Failed to set up trust dns resolver with system \
config: {}",
e
);
Error::bad_config(
"Failed to set up trust dns resolver with system \
config.",
)
})?,
dns_resolver,
actual_destination_cache: Arc::new(
RwLock::new(WellKnownMap::new()),
),