mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-09-08 13:04:26 +08:00
parent
0ef711fc3c
commit
a9fbfc2a8e
2 changed files with 10 additions and 6 deletions
|
@ -17,7 +17,7 @@ use jmap_client::client::Credentials;
|
|||
use modules::{
|
||||
UnwrapResult,
|
||||
cli::{Cli, Client, Commands},
|
||||
is_localhost,
|
||||
host, is_localhost,
|
||||
};
|
||||
use reqwest::{Method, StatusCode, header::AUTHORIZATION};
|
||||
use serde::{Deserialize, Serialize, de::DeserializeOwned};
|
||||
|
@ -191,6 +191,7 @@ impl Client {
|
|||
jmap_client::client::Client::new()
|
||||
.credentials(self.credentials)
|
||||
.accept_invalid_certs(is_localhost(&self.url))
|
||||
.follow_redirects([host(&self.url).expect("Invalid host").to_owned()])
|
||||
.timeout(Duration::from_secs(self.timeout.unwrap_or(60)))
|
||||
.connect(&self.url)
|
||||
.await
|
||||
|
|
|
@ -235,13 +235,16 @@ pub async fn name_to_id(client: &Client, name: &str) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_localhost(url: &str) -> bool {
|
||||
pub fn host(url: &str) -> Option<&str> {
|
||||
url.split_once("://")
|
||||
.map(|(_, url)| url.split_once('/').map_or(url, |(host, _)| host))
|
||||
.is_some_and(|host| {
|
||||
let host = host.rsplit_once(':').map_or(host, |(host, _)| host);
|
||||
host == "localhost" || host == "127.0.0.1" || host == "[::1]"
|
||||
})
|
||||
}
|
||||
|
||||
pub fn is_localhost(url: &str) -> bool {
|
||||
host(url).is_some_and(|host| {
|
||||
let host = host.rsplit_once(':').map_or(host, |(host, _)| host);
|
||||
host == "localhost" || host == "127.0.0.1" || host == "[::1]"
|
||||
})
|
||||
}
|
||||
|
||||
pub trait OAuthResponse {
|
||||
|
|
Loading…
Add table
Reference in a new issue