mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
chore: improve logging
This commit is contained in:
parent
0c9b8e6c63
commit
f32bc244a7
@ -19,7 +19,7 @@ use gpapi::{
|
|||||||
GP_USER_AGENT,
|
GP_USER_AGENT,
|
||||||
};
|
};
|
||||||
use inquire::{Password, PasswordDisplayMode, Select, Text};
|
use inquire::{Password, PasswordDisplayMode, Select, Text};
|
||||||
use log::info;
|
use log::{info, warn};
|
||||||
use openconnect::Vpn;
|
use openconnect::Vpn;
|
||||||
|
|
||||||
use crate::{cli::SharedArgs, GP_CLIENT_LOCK_FILE};
|
use crate::{cli::SharedArgs, GP_CLIENT_LOCK_FILE};
|
||||||
@ -203,7 +203,7 @@ impl<'a> ConnectHandler<'a> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Failed to connect portal with prelogin: {}", err);
|
warn!("Failed to connect portal with prelogin: {}", err);
|
||||||
if err.root_cause().downcast_ref::<PortalError>().is_some() {
|
if err.root_cause().downcast_ref::<PortalError>().is_some() {
|
||||||
info!("Trying the gateway authentication workflow...");
|
info!("Trying the gateway authentication workflow...");
|
||||||
self.connect_gateway_with_prelogin(server).await?;
|
self.connect_gateway_with_prelogin(server).await?;
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Log the detailed error message when network error occurs
|
||||||
|
|
||||||
## 2.4.0 - 2024-12-26
|
## 2.4.0 - 2024-12-26
|
||||||
|
|
||||||
- Upgrade to Tauri 2.0
|
- Upgrade to Tauri 2.0
|
||||||
|
@ -4,10 +4,13 @@ use thiserror::Error;
|
|||||||
pub enum PortalError {
|
pub enum PortalError {
|
||||||
#[error("Prelogin error: {0}")]
|
#[error("Prelogin error: {0}")]
|
||||||
PreloginError(String),
|
PreloginError(String),
|
||||||
|
|
||||||
#[error("Portal config error: {0}")]
|
#[error("Portal config error: {0}")]
|
||||||
ConfigError(String),
|
ConfigError(String),
|
||||||
#[error("Network error: {0}")]
|
|
||||||
|
#[error(transparent)]
|
||||||
NetworkError(#[from] reqwest::Error),
|
NetworkError(#[from] reqwest::Error),
|
||||||
|
|
||||||
#[error("TLS error")]
|
#[error("TLS error")]
|
||||||
TlsError,
|
TlsError,
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,10 @@ pub async fn gateway_login(gateway: &str, cred: &Credential, gp_params: &GpParam
|
|||||||
|
|
||||||
info!("Perform gateway login, user_agent: {}", gp_params.user_agent());
|
info!("Perform gateway login, user_agent: {}", gp_params.user_agent());
|
||||||
|
|
||||||
let res = client
|
let res = client.post(&login_url).form(¶ms).send().await.map_err(|e| {
|
||||||
.post(&login_url)
|
warn!("Network error: {:?}", e);
|
||||||
.form(¶ms)
|
anyhow::anyhow!(PortalError::NetworkError(e))
|
||||||
.send()
|
})?;
|
||||||
.await
|
|
||||||
.map_err(|e| anyhow::anyhow!(PortalError::NetworkError(e)))?;
|
|
||||||
|
|
||||||
let res = parse_gp_response(res).await.map_err(|err| {
|
let res = parse_gp_response(res).await.map_err(|err| {
|
||||||
warn!("{err}");
|
warn!("{err}");
|
||||||
|
@ -111,12 +111,10 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara
|
|||||||
|
|
||||||
info!("Retrieve the portal config, user_agent: {}", gp_params.user_agent());
|
info!("Retrieve the portal config, user_agent: {}", gp_params.user_agent());
|
||||||
|
|
||||||
let res = client
|
let res = client.post(&url).form(¶ms).send().await.map_err(|e| {
|
||||||
.post(&url)
|
warn!("Network error: {:?}", e);
|
||||||
.form(¶ms)
|
anyhow::anyhow!(PortalError::NetworkError(e))
|
||||||
.send()
|
})?;
|
||||||
.await
|
|
||||||
.map_err(|e| anyhow::anyhow!(PortalError::NetworkError(e)))?;
|
|
||||||
|
|
||||||
let res_xml = parse_gp_response(res).await.or_else(|err| {
|
let res_xml = parse_gp_response(res).await.or_else(|err| {
|
||||||
if err.status == StatusCode::NOT_FOUND {
|
if err.status == StatusCode::NOT_FOUND {
|
||||||
|
@ -116,12 +116,10 @@ pub async fn prelogin(portal: &str, gp_params: &GpParams) -> anyhow::Result<Prel
|
|||||||
|
|
||||||
let client = Client::try_from(gp_params)?;
|
let client = Client::try_from(gp_params)?;
|
||||||
|
|
||||||
let res = client
|
let res = client.post(&prelogin_url).form(¶ms).send().await.map_err(|e| {
|
||||||
.post(&prelogin_url)
|
warn!("Network error: {:?}", e);
|
||||||
.form(¶ms)
|
anyhow::anyhow!(PortalError::NetworkError(e))
|
||||||
.send()
|
})?;
|
||||||
.await
|
|
||||||
.map_err(|e| anyhow::anyhow!(PortalError::NetworkError(e)))?;
|
|
||||||
|
|
||||||
let res_xml = parse_gp_response(res).await.or_else(|err| {
|
let res_xml = parse_gp_response(res).await.or_else(|err| {
|
||||||
if err.status == StatusCode::NOT_FOUND {
|
if err.status == StatusCode::NOT_FOUND {
|
||||||
|
@ -14,12 +14,17 @@ BuildRequires: cargo
|
|||||||
BuildRequires: jq
|
BuildRequires: jq
|
||||||
BuildRequires: pkg-config
|
BuildRequires: pkg-config
|
||||||
BuildRequires: openconnect-devel
|
BuildRequires: openconnect-devel
|
||||||
BuildRequires: openssl-devel
|
BuildRequires: (openssl-devel or libopenssl-devel)
|
||||||
BuildRequires: wget
|
BuildRequires: wget
|
||||||
BuildRequires: file
|
BuildRequires: file
|
||||||
BuildRequires: perl
|
BuildRequires: perl
|
||||||
|
|
||||||
BuildRequires: (webkit2gtk4.1-devel or webkit2gtk3-soup2-devel)
|
%if 0%{?suse_version}
|
||||||
|
BuildRequires: webkit2gtk3-devel
|
||||||
|
%else
|
||||||
|
BuildRequires: webkit2gtk4.1-devel
|
||||||
|
%endif
|
||||||
|
|
||||||
BuildRequires: (libappindicator-gtk3-devel or libappindicator3-1)
|
BuildRequires: (libappindicator-gtk3-devel or libappindicator3-1)
|
||||||
BuildRequires: (librsvg2-devel or librsvg-devel)
|
BuildRequires: (librsvg2-devel or librsvg-devel)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user