preliminary get-signing-keys command
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
c64adbec0e
commit
f841c2356d
2 changed files with 57 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap},
|
collections::{BTreeMap, HashMap},
|
||||||
|
fmt::Write,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
@ -605,6 +606,50 @@ pub(super) async fn force_set_room_state_from_server(
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) async fn get_signing_keys(
|
||||||
|
_body: Vec<&str>, server_name: Option<Box<ServerName>>, _cached: bool,
|
||||||
|
) -> Result<RoomMessageEventContent> {
|
||||||
|
let server_name = server_name.unwrap_or_else(|| services().server.config.server_name.clone().into());
|
||||||
|
let signing_keys = services().globals.signing_keys_for(&server_name)?;
|
||||||
|
|
||||||
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||||
|
"```rs\n{signing_keys:#?}\n```"
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(super) async fn get_verify_keys(
|
||||||
|
_body: Vec<&str>, server_name: Option<Box<ServerName>>, cached: bool,
|
||||||
|
) -> Result<RoomMessageEventContent> {
|
||||||
|
let server_name = server_name.unwrap_or_else(|| services().server.config.server_name.clone().into());
|
||||||
|
let mut out = String::new();
|
||||||
|
|
||||||
|
if cached {
|
||||||
|
writeln!(out, "| Key ID | VerifyKey |")?;
|
||||||
|
writeln!(out, "| --- | --- |")?;
|
||||||
|
for (key_id, verify_key) in services().globals.verify_keys_for(&server_name)? {
|
||||||
|
writeln!(out, "| {key_id} | {verify_key:?} |")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(RoomMessageEventContent::notice_markdown(out));
|
||||||
|
}
|
||||||
|
|
||||||
|
let signature_ids: Vec<String> = Vec::new();
|
||||||
|
let keys = services()
|
||||||
|
.rooms
|
||||||
|
.event_handler
|
||||||
|
.fetch_signing_keys_for_server(&server_name, signature_ids)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
writeln!(out, "| Key ID | Public Key |")?;
|
||||||
|
writeln!(out, "| --- | --- |")?;
|
||||||
|
for (key_id, key) in keys {
|
||||||
|
writeln!(out, "| {key_id} | {key} |")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(RoomMessageEventContent::notice_markdown(out))
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) async fn resolve_true_destination(
|
pub(super) async fn resolve_true_destination(
|
||||||
_body: Vec<&str>, server_name: Box<ServerName>, no_cache: bool,
|
_body: Vec<&str>, server_name: Box<ServerName>, no_cache: bool,
|
||||||
) -> Result<RoomMessageEventContent> {
|
) -> Result<RoomMessageEventContent> {
|
||||||
|
|
|
@ -76,6 +76,14 @@ pub(super) enum DebugCommand {
|
||||||
room_id: OwnedRoomOrAliasId,
|
room_id: OwnedRoomOrAliasId,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// - Get and display signing keys from local cache or remote server.
|
||||||
|
GetSigningKeys {
|
||||||
|
server_name: Option<Box<ServerName>>,
|
||||||
|
|
||||||
|
#[arg(short, long)]
|
||||||
|
cached: bool,
|
||||||
|
},
|
||||||
|
|
||||||
/// - Sends a federation request to the remote server's
|
/// - Sends a federation request to the remote server's
|
||||||
/// `/_matrix/federation/v1/version` endpoint and measures the latency it
|
/// `/_matrix/federation/v1/version` endpoint and measures the latency it
|
||||||
/// took for the server to respond
|
/// took for the server to respond
|
||||||
|
@ -177,6 +185,10 @@ pub(super) async fn process(command: DebugCommand, body: Vec<&str>) -> Result<Ro
|
||||||
DebugCommand::Echo {
|
DebugCommand::Echo {
|
||||||
message,
|
message,
|
||||||
} => echo(body, message).await?,
|
} => echo(body, message).await?,
|
||||||
|
DebugCommand::GetSigningKeys {
|
||||||
|
server_name,
|
||||||
|
cached,
|
||||||
|
} => get_signing_keys(body, server_name, cached).await?,
|
||||||
DebugCommand::GetAuthChain {
|
DebugCommand::GetAuthChain {
|
||||||
event_id,
|
event_id,
|
||||||
} => get_auth_chain(body, event_id).await?,
|
} => get_auth_chain(body, event_id).await?,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue