mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-17 13:46:27 -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
@@ -122,7 +122,7 @@ impl Cli {
|
||||
let browser = self
|
||||
.browser
|
||||
.as_deref()
|
||||
.or_else(|| self.default_browser.then(|| "default"));
|
||||
.or_else(|| self.default_browser.then_some("default"));
|
||||
|
||||
#[cfg(not(feature = "webview-auth"))]
|
||||
let browser = self.browser.as_deref().or(Some("default"));
|
||||
|
||||
@@ -77,7 +77,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
openconnect_set_loglevel(vpninfo, PRG_TRACE);
|
||||
openconnect_init_ssl();
|
||||
openconnect_set_protocol(vpninfo, "gp");
|
||||
openconnect_set_hostname(vpninfo, options->server);
|
||||
openconnect_parse_url(vpninfo, options->server);
|
||||
openconnect_set_cookie(vpninfo, options->cookie);
|
||||
|
||||
if (options->os) {
|
||||
|
||||
@@ -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