mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 12:16:54 +00:00
feat: Move ping command to federation group
This commit is contained in:
4 files changed
+45
-45
No files matched your search
@@ -513,41 +513,6 @@ impl crate::Context<'_> {
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn ping(&self, server: OwnedServerName) -> Result {
|
||||
if server == self.services.globals.server_name() {
|
||||
return Err!("Not allowed to send federation requests to ourselves.");
|
||||
}
|
||||
|
||||
let timer = tokio::time::Instant::now();
|
||||
|
||||
match self
|
||||
.services
|
||||
.sending
|
||||
.send_unauthenticated_request(
|
||||
&server,
|
||||
ruma::api::federation::discovery::get_server_version::v1::Request::new(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
| Err(e) => {
|
||||
return Err!("Failed sending federation request to specified server:\n\n{e}");
|
||||
},
|
||||
| Ok(response) => {
|
||||
let ping_time = timer.elapsed();
|
||||
let json_text_res = serde_json::to_string_pretty(&response.server);
|
||||
|
||||
let out = if let Ok(json) = json_text_res {
|
||||
format!("Got response which took {ping_time:?} time:\n```json\n{json}\n```")
|
||||
} else {
|
||||
format!("Got non-JSON response which took {ping_time:?} time:\n{response:?}")
|
||||
};
|
||||
|
||||
write!(self, "{out}")
|
||||
},
|
||||
}
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn force_device_list_updates(&self) -> Result {
|
||||
// Force E2EE device list updates for all users
|
||||
self.services
|
||||
|
||||
@@ -80,13 +80,6 @@ pub enum DebugCommand {
|
||||
force: bool,
|
||||
},
|
||||
|
||||
/// Sends a federation request to the remote server's
|
||||
/// `/_matrix/federation/v1/version` endpoint and measures the latency it
|
||||
/// took for the server to respond
|
||||
Ping {
|
||||
server: OwnedServerName,
|
||||
},
|
||||
|
||||
/// Forces device lists for all local and remote users to be updated (as
|
||||
/// having new keys available)
|
||||
ForceDeviceListUpdates,
|
||||
|
||||
@@ -121,4 +121,35 @@ impl crate::Context<'_> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) async fn ping(&self, server: OwnedServerName) -> Result {
|
||||
let timer = tokio::time::Instant::now();
|
||||
|
||||
match self
|
||||
.services
|
||||
.sending
|
||||
.send_unauthenticated_request(
|
||||
&server,
|
||||
ruma::api::federation::discovery::get_server_version::v1::Request::new(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
| Err(e) => {
|
||||
return Err!("Failed sending federation request to specified server:\n\n{e}");
|
||||
},
|
||||
| Ok(response) => {
|
||||
let ping_time = timer.elapsed();
|
||||
let json_text_res = serde_json::to_string_pretty(&response.server);
|
||||
|
||||
let out = if let Ok(json) = json_text_res {
|
||||
format!("Got response which took {ping_time:?} time:\n```json\n{json}\n```")
|
||||
} else {
|
||||
format!("Got non-JSON response which took {ping_time:?} time:\n{response:?}")
|
||||
};
|
||||
|
||||
write!(self, "{out}")
|
||||
},
|
||||
}
|
||||
.await
|
||||
}
|
||||
}
|
||||
@@ -10,19 +10,21 @@ use crate::admin_command_dispatch;
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum FederationCommand {
|
||||
/// List all rooms we are currently handling an incoming pdu from
|
||||
#[clap(name="incoming", alias="inbound")]
|
||||
#[clap(name = "incoming", alias = "inbound")]
|
||||
IncomingFederation,
|
||||
|
||||
/// Disables incoming federation handling for a room.
|
||||
///
|
||||
/// The room can still be used locally, but events from other servers will stop being received.
|
||||
/// The room can still be used locally, but events from other servers will
|
||||
/// stop being received.
|
||||
DisableRoom {
|
||||
room: OwnedRoomOrAliasId,
|
||||
},
|
||||
|
||||
/// Enables incoming federation handling for a room again.
|
||||
///
|
||||
/// This does not unban the room if it was banned, it only re-enables incoming events.
|
||||
/// This does not unban the room if it was banned, it only re-enables
|
||||
/// incoming events.
|
||||
EnableRoom {
|
||||
room: OwnedRoomOrAliasId,
|
||||
},
|
||||
@@ -38,4 +40,13 @@ pub enum FederationCommand {
|
||||
GetSigningKeys {
|
||||
server_name: OwnedServerName,
|
||||
},
|
||||
|
||||
/// Makes a federation request to the remote server, to test connectivity.
|
||||
///
|
||||
/// The request is made to the federation version endpoint, which if
|
||||
/// successful, will also reveal how long the request took and what the
|
||||
/// remote server's software is.
|
||||
Ping {
|
||||
server_name: OwnedServerName,
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user