mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-20 06:56:17 -05:00
refactor: improve error handling and update deprecation warnings in ConnectHandler
This commit is contained in:
1 file changed
+8
-8
@@ -1,6 +1,6 @@
|
|||||||
use std::{borrow::Cow, cell::RefCell, fs, sync::Arc};
|
use std::{borrow::Cow, cell::RefCell, fs, sync::Arc};
|
||||||
|
|
||||||
use anyhow::bail;
|
use anyhow::{Context, bail};
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use common::constants::{GP_CLIENT_VERSION, GP_USER_AGENT};
|
use common::constants::{GP_CLIENT_VERSION, GP_USER_AGENT};
|
||||||
use gpapi::{
|
use gpapi::{
|
||||||
@@ -211,11 +211,15 @@ impl<'a> ConnectHandler<'a> {
|
|||||||
|
|
||||||
// Warn if deprecated options are used and will be removed in the future
|
// Warn if deprecated options are used and will be removed in the future
|
||||||
if self.args.csd_user.is_some() {
|
if self.args.csd_user.is_some() {
|
||||||
warn!("The '--csd-user' option is deprecated and will be removed in future releases, please use the '--hip-user' option instead");
|
warn!(
|
||||||
|
"The '--csd-user' option is deprecated and will be removed in future releases, please use the '--hip-user' option instead"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.args.csd_wrapper.is_some() {
|
if self.args.csd_wrapper.is_some() {
|
||||||
warn!("The '--csd-wrapper' option is deprecated and will be removed in future releases, please use the '--hip' option instead");
|
warn!(
|
||||||
|
"The '--csd-wrapper' option is deprecated and will be removed in future releases, please use the '--hip' option instead"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.latest_key_password.replace(self.args.key_password.clone());
|
self.latest_key_password.replace(self.args.key_password.clone());
|
||||||
@@ -516,7 +520,6 @@ impl<'a> ConnectHandler<'a> {
|
|||||||
|
|
||||||
self.args.csd_user.clone()
|
self.args.csd_user.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_cookie_from_stdin() -> anyhow::Result<Credential> {
|
fn read_cookie_from_stdin() -> anyhow::Result<Credential> {
|
||||||
@@ -525,10 +528,7 @@ fn read_cookie_from_stdin() -> anyhow::Result<Credential> {
|
|||||||
let mut cookie = String::new();
|
let mut cookie = String::new();
|
||||||
std::io::stdin().read_line(&mut cookie)?;
|
std::io::stdin().read_line(&mut cookie)?;
|
||||||
|
|
||||||
let Ok(auth_result) = serde_json::from_str::<SamlAuthResult>(cookie.trim_end()) else {
|
let auth_result = serde_json::from_str::<SamlAuthResult>(cookie.trim_end()).context("Failed to parse auth data")?;
|
||||||
bail!("Failed to parse auth data")
|
|
||||||
};
|
|
||||||
|
|
||||||
Credential::try_from(auth_result)
|
Credential::try_from(auth_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user