mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 22:46:14 -05:00
feat: update VPN connection to parse URL and ensure HTTPS prefix
This commit is contained in:
3 files changed
+12
-6
No files matched your search
@@ -36,7 +36,13 @@ pub struct Vpn {
|
||||
|
||||
impl Vpn {
|
||||
pub fn builder(server: &str, cookie: &str) -> VpnBuilder {
|
||||
VpnBuilder::new(server, cookie)
|
||||
// prepend "https://" to the server if it doesn't already start with it
|
||||
let server = if server.starts_with("https://") {
|
||||
server.to_string()
|
||||
} else {
|
||||
format!("https://{}", server)
|
||||
};
|
||||
VpnBuilder::new(server, cookie.to_string())
|
||||
}
|
||||
|
||||
pub fn connect(&self, on_connected: impl FnOnce() + 'static + Send + Sync) -> i32 {
|
||||
@@ -134,10 +140,10 @@ pub struct VpnBuilder {
|
||||
}
|
||||
|
||||
impl VpnBuilder {
|
||||
fn new(server: &str, cookie: &str) -> Self {
|
||||
fn new(server: String, cookie: String) -> Self {
|
||||
Self {
|
||||
server: server.to_string(),
|
||||
cookie: cookie.to_string(),
|
||||
server,
|
||||
cookie,
|
||||
script: None,
|
||||
interface: None,
|
||||
|
||||
|
||||
Reference in new issue
Block a user