mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Handle portal endpoint network error
This commit is contained in:
@@ -6,6 +6,6 @@ pub enum PortalError {
|
||||
PreloginError(String),
|
||||
#[error("Portal config error: {0}")]
|
||||
ConfigError(String),
|
||||
#[error("Gateway error: {0}")]
|
||||
GatewayError(String),
|
||||
#[error("Network error: {0}")]
|
||||
NetworkError(String),
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ pub async fn gateway_login(gateway: &str, cred: &Credential, gp_params: &GpParam
|
||||
.form(¶ms)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!(PortalError::GatewayError(e.to_string())))?;
|
||||
.map_err(|e| anyhow::anyhow!(PortalError::NetworkError(e.to_string())))?;
|
||||
|
||||
let status = res.status();
|
||||
|
||||
|
@@ -102,7 +102,12 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara
|
||||
|
||||
info!("Portal config, user_agent: {}", gp_params.user_agent());
|
||||
|
||||
let res = client.post(&url).form(¶ms).send().await?;
|
||||
let res = client
|
||||
.post(&url)
|
||||
.form(¶ms)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!(PortalError::NetworkError(e.to_string())))?;
|
||||
let status = res.status();
|
||||
|
||||
if status == StatusCode::NOT_FOUND {
|
||||
|
@@ -118,7 +118,12 @@ pub async fn prelogin(portal: &str, gp_params: &GpParams) -> anyhow::Result<Prel
|
||||
.user_agent(user_agent)
|
||||
.build()?;
|
||||
|
||||
let res = client.post(&prelogin_url).form(¶ms).send().await?;
|
||||
let res = client
|
||||
.post(&prelogin_url)
|
||||
.form(¶ms)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!(PortalError::NetworkError(e.to_string())))?;
|
||||
let status = res.status();
|
||||
|
||||
if status == StatusCode::NOT_FOUND {
|
||||
|
Reference in New Issue
Block a user