Files
continuwuity/src/service/resolver/mod.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.0 KiB
Rust
Raw Normal View History

pub mod actual;
pub mod cache;
mod dns;
pub mod fed;
mod tests;
2024-07-16 22:00:54 +00:00
2025-01-22 02:16:51 +00:00
use std::sync::Arc;
use conduwuit::{arrayvec::ArrayString, utils::MutexMap, Result, Server};
2024-07-16 22:00:54 +00:00
use self::{cache::Cache, dns::Resolver};
use crate::{client, Dep};
2024-07-16 22:00:54 +00:00
pub struct Service {
pub cache: Arc<Cache>,
pub resolver: Arc<Resolver>,
2025-01-22 06:57:18 +00:00
resolving: Resolving,
2024-07-18 06:37:47 +00:00
services: Services,
}
struct Services {
server: Arc<Server>,
client: Dep<client::Service>,
2024-07-16 22:00:54 +00:00
}
2025-01-22 06:57:18 +00:00
type Resolving = MutexMap<NameBuf, ()>;
type NameBuf = ArrayString<256>;
2024-07-16 22:00:54 +00:00
impl crate::Service for Service {
#[allow(clippy::as_conversions, clippy::cast_sign_loss, clippy::cast_possible_truncation)]
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
2025-01-22 02:16:51 +00:00
let cache = Cache::new(&args);
2024-07-16 22:00:54 +00:00
Ok(Arc::new(Self {
cache: cache.clone(),
resolver: Resolver::build(args.server, cache)?,
2025-01-22 06:57:18 +00:00
resolving: MutexMap::new(),
2024-07-18 06:37:47 +00:00
services: Services {
server: args.server.clone(),
client: args.depend::<client::Service>("client"),
},
2024-07-16 22:00:54 +00:00
}))
}
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
}