mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
38 lines
856 B
Rust
38 lines
856 B
Rust
use thiserror::Error;
|
|
|
|
#[derive(Error, Debug)]
|
|
pub enum PortalError {
|
|
#[error("Prelogin error: {0}")]
|
|
PreloginError(String),
|
|
#[error("Portal config error: {0}")]
|
|
ConfigError(String),
|
|
#[error("Network error: {0}")]
|
|
NetworkError(#[from] reqwest::Error),
|
|
#[error("TLS error")]
|
|
TlsError,
|
|
}
|
|
|
|
impl PortalError {
|
|
pub fn is_legacy_openssl_error(&self) -> bool {
|
|
format!("{:?}", self).contains("unsafe legacy renegotiation")
|
|
}
|
|
|
|
pub fn is_tls_error(&self) -> bool {
|
|
matches!(self, PortalError::TlsError) || format!("{:?}", self).contains("certificate verify failed")
|
|
}
|
|
}
|
|
|
|
#[derive(Error, Debug)]
|
|
pub enum AuthDataParseError {
|
|
#[error("No auth data found")]
|
|
NotFound,
|
|
#[error("Invalid auth data")]
|
|
Invalid,
|
|
}
|
|
|
|
impl AuthDataParseError {
|
|
pub fn is_invalid(&self) -> bool {
|
|
matches!(self, AuthDataParseError::Invalid)
|
|
}
|
|
}
|