mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-29 11:57:32 +00:00
refactor: Clean up acquire_keys_as_notary
This commit is contained in:
1 parent
5e971aef3c
commit
a31cbce31e
3 files changed
+135
-173
No files matched your search
@@ -224,7 +224,7 @@ impl Service {
|
||||
/// when acting as a notary server. This limits origin lookups to once per
|
||||
/// minute, which prevents amplification attacks.
|
||||
#[must_use]
|
||||
pub fn notary_may_contact_origin(&self, server_name: &ServerName) -> bool {
|
||||
pub fn origin_not_contacted_recently(&self, server_name: &ServerName) -> bool {
|
||||
if server_name == self.services.server.name {
|
||||
// We always intercept origin requests to us with
|
||||
// build_server_keys_response, so this is equivalent to
|
||||
|
||||
@@ -2,7 +2,8 @@ use conduwuit::{
|
||||
Err, Result, matrix::event::gen_event_id_canonical_json, trace, utils::to_canonical_object,
|
||||
};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, ServerName, SigningKeyAlgorithm,
|
||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, ServerName, ServerSigningKeyId,
|
||||
SigningKeyAlgorithm,
|
||||
api::federation::discovery::ServerSigningKeys,
|
||||
room_version_rules::RoomVersionRules,
|
||||
serde::{Base64, Raw, base64::Standard},
|
||||
@@ -35,6 +36,17 @@ impl TryFrom<&Raw<ServerSigningKeys>> for IncomingServerKeys {
|
||||
}
|
||||
}
|
||||
|
||||
impl IncomingServerKeys {
|
||||
/// Returns an iterator of every key ID in this key response.
|
||||
pub fn all_key_ids(&self) -> impl Iterator<Item = &ServerSigningKeyId> {
|
||||
self.parsed
|
||||
.verify_keys
|
||||
.keys()
|
||||
.chain(self.parsed.old_verify_keys.keys())
|
||||
.map(|key| &**key)
|
||||
}
|
||||
}
|
||||
|
||||
impl super::Service {
|
||||
/// Validates the incoming event only using locally known verification keys.
|
||||
/// Inserts the calculated event ID into the event_id field upon success.
|
||||
|
||||
Reference in new issue
Block a user