mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-16 20:49:05 -04:00
feat(sdk): Detect invalid .well-known endpoint response
This commit is contained in:
@@ -3,7 +3,11 @@ use std::sync::Arc;
|
||||
use matrix_sdk_base::{locks::RwLock, store::StoreConfig, BaseClient, StateStore};
|
||||
use ruma::{
|
||||
api::{
|
||||
client::discover::{discover_homeserver, get_supported_versions},
|
||||
client::{
|
||||
discover::{discover_homeserver, get_supported_versions},
|
||||
Error,
|
||||
},
|
||||
error::FromHttpResponseError,
|
||||
MatrixVersion,
|
||||
},
|
||||
ServerName, UserId,
|
||||
@@ -312,7 +316,11 @@ impl ClientBuilder {
|
||||
None,
|
||||
[MatrixVersion::V1_0].into_iter().collect(),
|
||||
)
|
||||
.await?;
|
||||
.await
|
||||
.map_err(|e| match e {
|
||||
HttpError::ClientApi(err) => ClientBuildError::AutoDiscovery(err),
|
||||
err => ClientBuildError::Http(err),
|
||||
})?;
|
||||
|
||||
well_known.homeserver.base_url
|
||||
}
|
||||
@@ -410,6 +418,10 @@ pub enum ClientBuildError {
|
||||
#[error("no homeserver or user ID was configured")]
|
||||
MissingHomeserver,
|
||||
|
||||
/// Error looking up the .well-known endpoint on auto-discovery
|
||||
#[error("Error looking up the .well-known endpoint on auto-discovery")]
|
||||
AutoDiscovery(FromHttpResponseError<Error>),
|
||||
|
||||
/// An error encountered when trying to parse the homeserver url.
|
||||
#[error(transparent)]
|
||||
Url(#[from] url::ParseError),
|
||||
|
||||
Reference in New Issue
Block a user