mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Compare commits
5 Commits
v2.0.0
...
66bcccabe4
Author | SHA1 | Date | |
---|---|---|---|
|
66bcccabe4 | ||
|
3736189308 | ||
|
c408482c55 | ||
|
00b0b8eb84 | ||
|
b14294f131 |
@@ -67,6 +67,7 @@ The GUI version is also available after you installed it. You can launch it from
|
|||||||
#### Install from PPA
|
#### Install from PPA
|
||||||
|
|
||||||
```
|
```
|
||||||
|
sudo apt-get install gir1.2-gtk-3.0 gir1.2-webkit2-4.0
|
||||||
sudo add-apt-repository ppa:yuezk/globalprotect-openconnect
|
sudo add-apt-repository ppa:yuezk/globalprotect-openconnect
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install globalprotect-openconnect
|
sudo apt-get install globalprotect-openconnect
|
||||||
@@ -123,7 +124,10 @@ Download the latest RPM package from [releases](https://github.com/yuezk/GlobalP
|
|||||||
|
|
||||||
### Other distributions
|
### Other distributions
|
||||||
|
|
||||||
The project depends on `openconnect >= 8.20`, `webkit2gtk`, `libsecret`, `libayatana-appindicator` or `libappindicator-gtk3`. You can install them first and then download the latest binary release (i.e., `*.bin.tar.gz`) from [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page.
|
- Install `openconnect >= 8.20`, `webkit2gtk`, `libsecret`, `libayatana-appindicator` or `libappindicator-gtk3`.
|
||||||
|
- Download `globalprotect-openconnect.tar.gz` from [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page.
|
||||||
|
- Extract the tarball and run `make build` to build the client.
|
||||||
|
- Run `make install` to install the client.
|
||||||
|
|
||||||
## About Trial
|
## About Trial
|
||||||
|
|
||||||
|
@@ -413,7 +413,19 @@ fn read_auth_data(main_resource: &WebResource, auth_result_tx: mpsc::UnboundedSe
|
|||||||
}
|
}
|
||||||
Err(AuthDataError::NotFound) => {
|
Err(AuthDataError::NotFound) => {
|
||||||
info!("No auth data found in headers, trying to read from body...");
|
info!("No auth data found in headers, trying to read from body...");
|
||||||
|
let url = main_resource.uri().unwrap_or("".into());
|
||||||
|
let is_acs_endpoint = url.contains("/SAML20/SP/ACS");
|
||||||
|
|
||||||
read_auth_data_from_body(main_resource, move |auth_result| {
|
read_auth_data_from_body(main_resource, move |auth_result| {
|
||||||
|
// If the endpoint is `/SAML20/SP/ACS` and no auth data found in body, it should be considered as invalid
|
||||||
|
let auth_result = auth_result.map_err(|err| {
|
||||||
|
if matches!(err, AuthDataError::NotFound) && is_acs_endpoint {
|
||||||
|
AuthDataError::Invalid
|
||||||
|
} else {
|
||||||
|
err
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
send_auth_result(&auth_result_tx, auth_result)
|
send_auth_result(&auth_result_tx, auth_result)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -37,6 +37,9 @@ pub(crate) struct ConnectArgs {
|
|||||||
#[arg(long, help = "Same as the '--csd-wrapper' option in the openconnect command")]
|
#[arg(long, help = "Same as the '--csd-wrapper' option in the openconnect command")]
|
||||||
csd_wrapper: Option<String>,
|
csd_wrapper: Option<String>,
|
||||||
|
|
||||||
|
#[arg(short, long, help = "Request MTU from server (legacy servers only)")]
|
||||||
|
mtu: Option<u32>,
|
||||||
|
|
||||||
#[arg(long, default_value = GP_USER_AGENT, help = "The user agent to use")]
|
#[arg(long, default_value = GP_USER_AGENT, help = "The user agent to use")]
|
||||||
user_agent: String,
|
user_agent: String,
|
||||||
#[arg(long, default_value = "Linux")]
|
#[arg(long, default_value = "Linux")]
|
||||||
@@ -152,12 +155,14 @@ impl<'a> ConnectHandler<'a> {
|
|||||||
|
|
||||||
async fn connect_gateway(&self, gateway: &str, cookie: &str) -> anyhow::Result<()> {
|
async fn connect_gateway(&self, gateway: &str, cookie: &str) -> anyhow::Result<()> {
|
||||||
let csd_uid = get_csd_uid(&self.args.csd_user)?;
|
let csd_uid = get_csd_uid(&self.args.csd_user)?;
|
||||||
|
let mtu = self.args.mtu.unwrap_or(0);
|
||||||
|
|
||||||
let vpn = Vpn::builder(gateway, cookie)
|
let vpn = Vpn::builder(gateway, cookie)
|
||||||
.user_agent(self.args.user_agent.clone())
|
.user_agent(self.args.user_agent.clone())
|
||||||
.script(self.args.script.clone())
|
.script(self.args.script.clone())
|
||||||
.csd_uid(csd_uid)
|
.csd_uid(csd_uid)
|
||||||
.csd_wrapper(self.args.csd_wrapper.clone())
|
.csd_wrapper(self.args.csd_wrapper.clone())
|
||||||
|
.mtu(mtu)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let vpn = Arc::new(vpn);
|
let vpn = Arc::new(vpn);
|
||||||
|
@@ -39,6 +39,7 @@ impl VpnTaskContext {
|
|||||||
.script(args.vpnc_script())
|
.script(args.vpnc_script())
|
||||||
.csd_uid(args.csd_uid())
|
.csd_uid(args.csd_uid())
|
||||||
.csd_wrapper(args.csd_wrapper())
|
.csd_wrapper(args.csd_wrapper())
|
||||||
|
.mtu(args.mtu())
|
||||||
.os(args.openconnect_os())
|
.os(args.openconnect_os())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@@ -34,6 +34,7 @@ pub struct ConnectArgs {
|
|||||||
user_agent: Option<String>,
|
user_agent: Option<String>,
|
||||||
csd_uid: u32,
|
csd_uid: u32,
|
||||||
csd_wrapper: Option<String>,
|
csd_wrapper: Option<String>,
|
||||||
|
mtu: u32,
|
||||||
os: Option<ClientOs>,
|
os: Option<ClientOs>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ impl ConnectArgs {
|
|||||||
os: None,
|
os: None,
|
||||||
csd_uid: 0,
|
csd_uid: 0,
|
||||||
csd_wrapper: None,
|
csd_wrapper: None,
|
||||||
|
mtu: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +74,10 @@ impl ConnectArgs {
|
|||||||
pub fn csd_wrapper(&self) -> Option<String> {
|
pub fn csd_wrapper(&self) -> Option<String> {
|
||||||
self.csd_wrapper.clone()
|
self.csd_wrapper.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn mtu(&self) -> u32 {
|
||||||
|
self.mtu
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Type)]
|
#[derive(Debug, Deserialize, Serialize, Type)]
|
||||||
@@ -103,6 +109,11 @@ impl ConnectRequest {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_mtu(mut self, mtu: u32) -> Self {
|
||||||
|
self.args.mtu = mtu;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn with_user_agent<T: Into<Option<String>>>(mut self, user_agent: T) -> Self {
|
pub fn with_user_agent<T: Into<Option<String>>>(mut self, user_agent: T) -> Self {
|
||||||
self.args.user_agent = user_agent.into();
|
self.args.user_agent = user_agent.into();
|
||||||
self
|
self
|
||||||
|
@@ -18,6 +18,8 @@ pub(crate) struct ConnectOptions {
|
|||||||
|
|
||||||
pub csd_uid: u32,
|
pub csd_uid: u32,
|
||||||
pub csd_wrapper: *const c_char,
|
pub csd_wrapper: *const c_char,
|
||||||
|
|
||||||
|
pub mtu: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[link(name = "vpn")]
|
#[link(name = "vpn")]
|
||||||
|
@@ -63,6 +63,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
INFO("OS: %s", options->os);
|
INFO("OS: %s", options->os);
|
||||||
INFO("CSD_USER: %d", options->csd_uid);
|
INFO("CSD_USER: %d", options->csd_uid);
|
||||||
INFO("CSD_WRAPPER: %s", options->csd_wrapper);
|
INFO("CSD_WRAPPER: %s", options->csd_wrapper);
|
||||||
|
INFO("MTU: %d", options->mtu);
|
||||||
|
|
||||||
vpninfo = openconnect_vpninfo_new(options->user_agent, validate_peer_cert, NULL, NULL, print_progress, NULL);
|
vpninfo = openconnect_vpninfo_new(options->user_agent, validate_peer_cert, NULL, NULL, print_progress, NULL);
|
||||||
|
|
||||||
@@ -97,6 +98,11 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
openconnect_setup_csd(vpninfo, options->csd_uid, 1, options->csd_wrapper);
|
openconnect_setup_csd(vpninfo, options->csd_uid, 1, options->csd_wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options->mtu > 0) {
|
||||||
|
int mtu = options->mtu < 576 ? 576 : options->mtu;
|
||||||
|
openconnect_set_reqmtu(vpninfo, mtu);
|
||||||
|
}
|
||||||
|
|
||||||
g_cmd_pipe_fd = openconnect_setup_cmd_pipe(vpninfo);
|
g_cmd_pipe_fd = openconnect_setup_cmd_pipe(vpninfo);
|
||||||
if (g_cmd_pipe_fd < 0)
|
if (g_cmd_pipe_fd < 0)
|
||||||
{
|
{
|
||||||
|
@@ -19,6 +19,8 @@ typedef struct vpn_options
|
|||||||
|
|
||||||
const uid_t csd_uid;
|
const uid_t csd_uid;
|
||||||
const char *csd_wrapper;
|
const char *csd_wrapper;
|
||||||
|
|
||||||
|
const int mtu;
|
||||||
} vpn_options;
|
} vpn_options;
|
||||||
|
|
||||||
int vpn_connect(const vpn_options *options, vpn_connected_callback callback);
|
int vpn_connect(const vpn_options *options, vpn_connected_callback callback);
|
||||||
|
@@ -21,6 +21,8 @@ pub struct Vpn {
|
|||||||
csd_uid: u32,
|
csd_uid: u32,
|
||||||
csd_wrapper: Option<CString>,
|
csd_wrapper: Option<CString>,
|
||||||
|
|
||||||
|
mtu: u32,
|
||||||
|
|
||||||
callback: OnConnectedCallback,
|
callback: OnConnectedCallback,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +64,8 @@ impl Vpn {
|
|||||||
|
|
||||||
csd_uid: self.csd_uid,
|
csd_uid: self.csd_uid,
|
||||||
csd_wrapper: Self::option_to_ptr(&self.csd_wrapper),
|
csd_wrapper: Self::option_to_ptr(&self.csd_wrapper),
|
||||||
|
|
||||||
|
mtu: self.mtu,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +86,8 @@ pub struct VpnBuilder {
|
|||||||
|
|
||||||
csd_uid: u32,
|
csd_uid: u32,
|
||||||
csd_wrapper: Option<String>,
|
csd_wrapper: Option<String>,
|
||||||
|
|
||||||
|
mtu: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VpnBuilder {
|
impl VpnBuilder {
|
||||||
@@ -94,6 +100,7 @@ impl VpnBuilder {
|
|||||||
os: None,
|
os: None,
|
||||||
csd_uid: 0,
|
csd_uid: 0,
|
||||||
csd_wrapper: None,
|
csd_wrapper: None,
|
||||||
|
mtu: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +129,11 @@ impl VpnBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn mtu(mut self, mtu: u32) -> Self {
|
||||||
|
self.mtu = mtu;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build(self) -> Vpn {
|
pub fn build(self) -> Vpn {
|
||||||
let user_agent = self.user_agent.unwrap_or_default();
|
let user_agent = self.user_agent.unwrap_or_default();
|
||||||
let script = self.script.or_else(find_default_vpnc_script).unwrap_or_default();
|
let script = self.script.or_else(find_default_vpnc_script).unwrap_or_default();
|
||||||
@@ -139,6 +151,8 @@ impl VpnBuilder {
|
|||||||
csd_uid: self.csd_uid,
|
csd_uid: self.csd_uid,
|
||||||
csd_wrapper: self.csd_wrapper.as_deref().map(Self::to_cstring),
|
csd_wrapper: self.csd_wrapper.as_deref().map(Self::to_cstring),
|
||||||
|
|
||||||
|
mtu: self.mtu,
|
||||||
|
|
||||||
callback: Default::default(),
|
callback: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user