tuwunel_admin/query/resolver/
destinations_cache.rs1use futures::StreamExt;
2use ruma::OwnedServerName;
3use tuwunel_core::{Result, utils::time};
4use tuwunel_service::resolver::cache::CachedDest;
5
6use crate::admin_command;
7
8#[admin_command]
9pub(super) async fn destinations_cache(&self, server_name: Option<OwnedServerName>) -> Result {
10 writeln!(self, "| Server Name | Destination | Hostname | Expires |").await?;
11 writeln!(self, "| ----------- | ----------- | -------- | ------- |").await?;
12
13 let mut destinations = self
14 .services
15 .resolver
16 .cache
17 .destinations()
18 .boxed();
19
20 while let Some((name, CachedDest { dest, host, expire })) = destinations.next().await {
21 if let Some(server_name) = server_name.as_ref()
22 && name != server_name
23 {
24 continue;
25 }
26
27 let expire = time::format(expire, "%+");
28 write!(self, "| {name} | {dest} | {host} | {expire} |\n").await?;
29 }
30
31 Ok(())
32}