rename Resolver -> FederationResolver and document

This commit is contained in:
Olivia Lee 2024-12-15 22:02:13 -08:00
parent e98dd5b9a3
commit e249aed1cb
No known key found for this signature in database
GPG key ID: 54D568A15B9CD1F9

View file

@ -141,21 +141,29 @@ impl Default for RotationHandler {
}
}
pub(crate) struct Resolver {
/// Resolver used for outgoing requests to the federation API.
///
/// Hostnames that have been mapped to a different domain by SRV records in
/// [server discovery][1] are resolved to the SRV record target. This is done to
/// get reqwest to check the TLS certificate against the correct hostname
/// required in steps 3.3, 3.4, and 4 of the server discovery spec.
///
/// [1]: https://spec.matrix.org/v1.12/server-server-api/#server-discovery
pub(crate) struct FederationResolver {
inner: GaiResolver,
overrides: Arc<StdRwLock<TlsNameMap>>,
}
impl Resolver {
impl FederationResolver {
pub(crate) fn new(overrides: Arc<StdRwLock<TlsNameMap>>) -> Self {
Resolver {
FederationResolver {
inner: GaiResolver::new(),
overrides,
}
}
}
impl Resolve for Resolver {
impl Resolve for FederationResolver {
#[tracing::instrument(skip(self))]
fn resolve(&self, name: Name) -> Resolving {
self.overrides
@ -234,7 +242,9 @@ impl Service {
let default_client = reqwest_client_builder(&config)?.build()?;
let federation_client = reqwest_client_builder(&config)?
.dns_resolver(Arc::new(Resolver::new(tls_name_override.clone())))
.dns_resolver(Arc::new(FederationResolver::new(
tls_name_override.clone(),
)))
.build()?;
// Supported and stable room versions