mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 14:36:15 -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
|
let browser = self
|
||||||
.browser
|
.browser
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.or_else(|| self.default_browser.then(|| "default"));
|
.or_else(|| self.default_browser.then_some("default"));
|
||||||
|
|
||||||
#[cfg(not(feature = "webview-auth"))]
|
#[cfg(not(feature = "webview-auth"))]
|
||||||
let browser = self.browser.as_deref().or(Some("default"));
|
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_set_loglevel(vpninfo, PRG_TRACE);
|
||||||
openconnect_init_ssl();
|
openconnect_init_ssl();
|
||||||
openconnect_set_protocol(vpninfo, "gp");
|
openconnect_set_protocol(vpninfo, "gp");
|
||||||
openconnect_set_hostname(vpninfo, options->server);
|
openconnect_parse_url(vpninfo, options->server);
|
||||||
openconnect_set_cookie(vpninfo, options->cookie);
|
openconnect_set_cookie(vpninfo, options->cookie);
|
||||||
|
|
||||||
if (options->os) {
|
if (options->os) {
|
||||||
|
|||||||
@@ -36,7 +36,13 @@ pub struct Vpn {
|
|||||||
|
|
||||||
impl Vpn {
|
impl Vpn {
|
||||||
pub fn builder(server: &str, cookie: &str) -> VpnBuilder {
|
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 {
|
pub fn connect(&self, on_connected: impl FnOnce() + 'static + Send + Sync) -> i32 {
|
||||||
@@ -134,10 +140,10 @@ pub struct VpnBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl VpnBuilder {
|
impl VpnBuilder {
|
||||||
fn new(server: &str, cookie: &str) -> Self {
|
fn new(server: String, cookie: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
server: server.to_string(),
|
server,
|
||||||
cookie: cookie.to_string(),
|
cookie,
|
||||||
script: None,
|
script: None,
|
||||||
interface: None,
|
interface: None,
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user