mirror of
				https://github.com/yuezk/GlobalProtect-openconnect.git
				synced 2025-05-20 07:26:58 -04:00 
			
		
		
		
	Update format
This commit is contained in:
		| @@ -19,8 +19,8 @@ use tokio_util::sync::CancellationToken; | ||||
| use webkit2gtk::{ | ||||
|   gio::Cancellable, | ||||
|   glib::{GString, TimeSpan}, | ||||
|   LoadEvent, SettingsExt, TLSErrorsPolicy, URIResponse, URIResponseExt, WebContextExt, WebResource, | ||||
|   WebResourceExt, WebView, WebViewExt, WebsiteDataManagerExtManual, WebsiteDataTypes, | ||||
|   LoadEvent, SettingsExt, TLSErrorsPolicy, URIResponse, URIResponseExt, WebContextExt, WebResource, WebResourceExt, | ||||
|   WebView, WebViewExt, WebsiteDataManagerExtManual, WebsiteDataTypes, | ||||
| }; | ||||
|  | ||||
| enum AuthDataError { | ||||
| @@ -216,9 +216,7 @@ impl<'a> AuthWindow<'a> { | ||||
|       if let Some(auth_result) = auth_result_rx.recv().await { | ||||
|         match auth_result { | ||||
|           Ok(auth_data) => return Ok(auth_data), | ||||
|           Err(AuthDataError::TlsError) => { | ||||
|             return Err(anyhow::anyhow!("TLS error: certificate verify failed")) | ||||
|           } | ||||
|           Err(AuthDataError::TlsError) => bail!("TLS error: certificate verify failed"), | ||||
|           Err(AuthDataError::NotFound) => { | ||||
|             info!("No auth data found, it may not be the /SAML20/SP/ACS endpoint"); | ||||
|  | ||||
| @@ -227,10 +225,7 @@ impl<'a> AuthWindow<'a> { | ||||
|               let window = Arc::clone(window); | ||||
|               let cancel_token = CancellationToken::new(); | ||||
|  | ||||
|               raise_window_cancel_token | ||||
|                 .write() | ||||
|                 .await | ||||
|                 .replace(cancel_token.clone()); | ||||
|               raise_window_cancel_token.write().await.replace(cancel_token.clone()); | ||||
|  | ||||
|               tokio::spawn(async move { | ||||
|                 let delay_secs = 1; | ||||
|   | ||||
| @@ -13,12 +13,7 @@ use tempfile::NamedTempFile; | ||||
|  | ||||
| use crate::auth_window::{portal_prelogin, AuthWindow}; | ||||
|  | ||||
| const VERSION: &str = concat!( | ||||
|   env!("CARGO_PKG_VERSION"), | ||||
|   " (", | ||||
|   compile_time::date_str!(), | ||||
|   ")" | ||||
| ); | ||||
| const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")"); | ||||
|  | ||||
| #[derive(Parser, Clone)] | ||||
| #[command(version = VERSION)] | ||||
|   | ||||
| @@ -9,12 +9,7 @@ use crate::{ | ||||
|   launch_gui::{LaunchGuiArgs, LaunchGuiHandler}, | ||||
| }; | ||||
|  | ||||
| const VERSION: &str = concat!( | ||||
|   env!("CARGO_PKG_VERSION"), | ||||
|   " (", | ||||
|   compile_time::date_str!(), | ||||
|   ")" | ||||
| ); | ||||
| const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")"); | ||||
|  | ||||
| pub(crate) struct SharedArgs { | ||||
|   pub(crate) fix_openssl: bool, | ||||
| @@ -53,10 +48,7 @@ struct Cli { | ||||
|   #[command(subcommand)] | ||||
|   command: CliCommand, | ||||
|  | ||||
|   #[arg( | ||||
|     long, | ||||
|     help = "Get around the OpenSSL `unsafe legacy renegotiation` error" | ||||
|   )] | ||||
|   #[arg(long, help = "Get around the OpenSSL `unsafe legacy renegotiation` error")] | ||||
|   fix_openssl: bool, | ||||
|   #[arg(long, help = "Ignore the TLS errors")] | ||||
|   ignore_tls_errors: bool, | ||||
|   | ||||
| @@ -21,17 +21,9 @@ use crate::{cli::SharedArgs, GP_CLIENT_LOCK_FILE}; | ||||
| pub(crate) struct ConnectArgs { | ||||
|   #[arg(help = "The portal server to connect to")] | ||||
|   server: String, | ||||
|   #[arg( | ||||
|     short, | ||||
|     long, | ||||
|     help = "The gateway to connect to, it will prompt if not specified" | ||||
|   )] | ||||
|   #[arg(short, long, help = "The gateway to connect to, it will prompt if not specified")] | ||||
|   gateway: Option<String>, | ||||
|   #[arg( | ||||
|     short, | ||||
|     long, | ||||
|     help = "The username to use, it will prompt if not specified" | ||||
|   )] | ||||
|   #[arg(short, long, help = "The username to use, it will prompt if not specified")] | ||||
|   user: Option<String>, | ||||
|   #[arg(long, short, help = "The VPNC script to use")] | ||||
|   script: Option<String>, | ||||
| @@ -174,11 +166,7 @@ impl<'a> ConnectHandler<'a> { | ||||
|     Ok(()) | ||||
|   } | ||||
|  | ||||
|   async fn obtain_credential( | ||||
|     &self, | ||||
|     prelogin: &Prelogin, | ||||
|     server: &str, | ||||
|   ) -> anyhow::Result<Credential> { | ||||
|   async fn obtain_credential(&self, prelogin: &Prelogin, server: &str) -> anyhow::Result<Credential> { | ||||
|     let is_gateway = prelogin.is_gateway(); | ||||
|  | ||||
|     match prelogin { | ||||
|   | ||||
| @@ -6,9 +6,7 @@ use clap::Parser; | ||||
| use gpapi::{ | ||||
|   process::gui_launcher::GuiLauncher, | ||||
|   service::{request::WsRequest, vpn_state::VpnState}, | ||||
|   utils::{ | ||||
|     crypto::generate_key, env_file, lock_file::LockFile, redact::Redaction, shutdown_signal, | ||||
|   }, | ||||
|   utils::{crypto::generate_key, env_file, lock_file::LockFile, redact::Redaction, shutdown_signal}, | ||||
|   GP_SERVICE_LOCK_FILE, | ||||
| }; | ||||
| use log::{info, warn, LevelFilter}; | ||||
| @@ -16,12 +14,7 @@ use tokio::sync::{mpsc, watch}; | ||||
|  | ||||
| use crate::{vpn_task::VpnTask, ws_server::WsServer}; | ||||
|  | ||||
| const VERSION: &str = concat!( | ||||
|   env!("CARGO_PKG_VERSION"), | ||||
|   " (", | ||||
|   compile_time::date_str!(), | ||||
|   ")" | ||||
| ); | ||||
| const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")"); | ||||
|  | ||||
| #[derive(Parser)] | ||||
| #[command(version = VERSION)] | ||||
| @@ -51,13 +44,7 @@ impl Cli { | ||||
|     let (vpn_state_tx, vpn_state_rx) = watch::channel(VpnState::Disconnected); | ||||
|  | ||||
|     let mut vpn_task = VpnTask::new(ws_req_rx, vpn_state_tx); | ||||
|     let ws_server = WsServer::new( | ||||
|       api_key.clone(), | ||||
|       ws_req_tx, | ||||
|       vpn_state_rx, | ||||
|       lock_file.clone(), | ||||
|       redaction, | ||||
|     ); | ||||
|     let ws_server = WsServer::new(api_key.clone(), ws_req_tx, vpn_state_rx, lock_file.clone(), redaction); | ||||
|  | ||||
|     let (shutdown_tx, mut shutdown_rx) = mpsc::channel::<()>(4); | ||||
|     let shutdown_tx_clone = shutdown_tx.clone(); | ||||
| @@ -76,11 +63,7 @@ impl Cli { | ||||
|     if no_gui { | ||||
|       info!("GUI is disabled"); | ||||
|     } else { | ||||
|       let envs = self | ||||
|         .env_file | ||||
|         .as_ref() | ||||
|         .map(env_file::load_env_vars) | ||||
|         .transpose()?; | ||||
|       let envs = self.env_file.as_ref().map(env_file::load_env_vars).transpose()?; | ||||
|  | ||||
|       let minimized = self.minimized; | ||||
|  | ||||
|   | ||||
| @@ -21,17 +21,11 @@ pub(crate) async fn active_gui(State(ctx): State<Arc<WsServerContext>>) -> impl | ||||
|   ctx.send_event(WsEvent::ActiveGui).await; | ||||
| } | ||||
|  | ||||
| pub(crate) async fn auth_data( | ||||
|   State(ctx): State<Arc<WsServerContext>>, | ||||
|   body: String, | ||||
| ) -> impl IntoResponse { | ||||
| pub(crate) async fn auth_data(State(ctx): State<Arc<WsServerContext>>, body: String) -> impl IntoResponse { | ||||
|   ctx.send_event(WsEvent::AuthData(body)).await; | ||||
| } | ||||
|  | ||||
| pub(crate) async fn ws_handler( | ||||
|   ws: WebSocketUpgrade, | ||||
|   State(ctx): State<Arc<WsServerContext>>, | ||||
| ) -> impl IntoResponse { | ||||
| pub(crate) async fn ws_handler(ws: WebSocketUpgrade, State(ctx): State<Arc<WsServerContext>>) -> impl IntoResponse { | ||||
|   ws.on_upgrade(move |socket| handle_socket(socket, ctx)) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -98,12 +98,7 @@ impl WsServer { | ||||
|     lock_file: Arc<LockFile>, | ||||
|     redaction: Arc<Redaction>, | ||||
|   ) -> Self { | ||||
|     let ctx = Arc::new(WsServerContext::new( | ||||
|       api_key, | ||||
|       ws_req_tx, | ||||
|       vpn_state_rx, | ||||
|       redaction, | ||||
|     )); | ||||
|     let ctx = Arc::new(WsServerContext::new(api_key, ws_req_tx, vpn_state_rx, redaction)); | ||||
|     let cancel_token = CancellationToken::new(); | ||||
|  | ||||
|     Self { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user