Skip to main content

tuwunel_admin/debug/
resolve_true_destination.rs

1use ruma::OwnedServerName;
2use tuwunel_core::{Err, Result};
3
4use crate::admin_command;
5
6#[admin_command]
7pub(super) async fn resolve_true_destination(
8	&self,
9	server_name: OwnedServerName,
10	no_cache: bool,
11) -> Result {
12	if !self.services.server.config.allow_federation {
13		return Err!("Federation is disabled on this homeserver.",);
14	}
15
16	if server_name == self.services.server.name {
17		return Err!(
18			"Not allowed to send federation requests to ourselves. Please use `get-pdu` for \
19			 fetching local PDUs.",
20		);
21	}
22
23	let actual = self
24		.services
25		.resolver
26		.resolve_actual_dest(&server_name, !no_cache)
27		.await?;
28
29	let msg = format!("Destination: {}\nHostname URI: {}", actual.dest, actual.host);
30	self.write_str(&msg).await
31}