1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-12-26 07:04:20 +01:00

Merge branch 'Nyaaori/fix-trusted-server-panic' into 'next'

Cleanly handle invalid response from trusted server instead of panicking

See merge request famedly/conduit!411
This commit is contained in:
Timo Kösters 2022-10-31 11:35:55 +00:00
commit e8e0a4dcc5
4 changed files with 17 additions and 5 deletions

View file

@ -103,7 +103,7 @@ pub async fn search_events_route(
.take(limit) .take(limit)
.collect(); .collect();
let next_batch = if results.len() < limit as usize { let next_batch = if results.len() < limit {
None None
} else { } else {
Some((skip + limit).to_string()) Some((skip + limit).to_string())

View file

@ -1,5 +1,4 @@
use std::collections::HashSet; use std::{collections::HashSet, mem};
use std::mem;
use ruma::{OwnedUserId, RoomId, UserId}; use ruma::{OwnedUserId, RoomId, UserId};

View file

@ -28,7 +28,10 @@ use http::{
}; };
use opentelemetry::trace::{FutureExt, Tracer}; use opentelemetry::trace::{FutureExt, Tracer};
use ruma::api::{ use ruma::api::{
client::{error::Error as RumaError, error::ErrorKind, uiaa::UiaaResponse}, client::{
error::{Error as RumaError, ErrorKind},
uiaa::UiaaResponse,
},
IncomingRequest, IncomingRequest,
}; };
use tokio::signal; use tokio::signal;

View file

@ -1464,7 +1464,17 @@ impl Service {
.write() .write()
.map_err(|_| Error::bad_database("RwLock is poisoned."))?; .map_err(|_| Error::bad_database("RwLock is poisoned."))?;
for k in keys.server_keys { for k in keys.server_keys {
let k = k.deserialize().unwrap(); let k = match k.deserialize() {
Ok(key) => key,
Err(e) => {
warn!(
"Received error {} while fetching keys from trusted server {}",
e, server
);
warn!("{}", k.into_json());
continue;
}
};
// TODO: Check signature from trusted server? // TODO: Check signature from trusted server?
servers.remove(&k.server_name); servers.remove(&k.server_name);