mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-20 15:06:14 -05:00
Release 3.6.0
This commit is contained in:
58 files changed
+2191
-642
No files matched your search
@@ -3,24 +3,32 @@ mod configuration;
|
||||
mod dns;
|
||||
mod ip_helper;
|
||||
mod recovery;
|
||||
mod system_tunnel;
|
||||
use configuration::Configuration;
|
||||
use std::io;
|
||||
pub use system_tunnel::SystemTunnel;
|
||||
|
||||
pub struct NetworkConfigurator {
|
||||
connection: Option<Connection>,
|
||||
recovery_key: String,
|
||||
system_tunnel: Option<SystemTunnel>,
|
||||
}
|
||||
struct Connection {
|
||||
dns: dns::Installed,
|
||||
network: ip_helper::Installed,
|
||||
}
|
||||
impl NetworkConfigurator {
|
||||
/// The owner supplies an HKLM key under its administrator-controlled namespace.
|
||||
/// Use a separate HKLM journal and DNS tag for an isolated network configuration.
|
||||
pub fn new(recovery_key: &str) -> io::Result<Self> {
|
||||
Self::with_owner(recovery_key, None)
|
||||
}
|
||||
|
||||
fn with_owner(recovery_key: &str, system_tunnel: Option<SystemTunnel>) -> io::Result<Self> {
|
||||
recovery::Journal::begin(recovery_key)?;
|
||||
Ok(Self {
|
||||
connection: None,
|
||||
recovery_key: recovery_key.into(),
|
||||
system_tunnel,
|
||||
})
|
||||
}
|
||||
pub fn configure(&mut self, reason: &str, environment: &[(String, Option<String>)]) -> io::Result<()> {
|
||||
@@ -30,7 +38,7 @@ impl NetworkConfigurator {
|
||||
let configuration = Configuration::parse(environment)?;
|
||||
self.disconnect()?;
|
||||
let network = ip_helper::Installed::apply(&configuration, &self.recovery_key)?;
|
||||
let dns = dns::Installed::apply(&configuration)?;
|
||||
let dns = dns::Installed::apply(&configuration, &self.recovery_key, self.system_tunnel.as_ref())?;
|
||||
self.connection = Some(Connection { dns, network });
|
||||
Ok(())
|
||||
}
|
||||
@@ -52,13 +60,18 @@ impl NetworkConfigurator {
|
||||
}
|
||||
}
|
||||
|
||||
/// Restore process-owned physical routes and DNS policy before service admission.
|
||||
/// Recover an isolated journal and only the DNS rules recorded under its name.
|
||||
pub fn recover(recovery_key: &str) -> io::Result<()> {
|
||||
recover_routes(recovery_key)?;
|
||||
dns::remove_journal_policy(recovery_key)
|
||||
}
|
||||
|
||||
fn recover_routes(recovery_key: &str) -> io::Result<()> {
|
||||
if let Some(journal) = recovery::Journal::open(recovery_key)? {
|
||||
for (name, route) in journal.routes()? {
|
||||
ip_helper::recover_route(&route)?;
|
||||
journal.forget(&name)?;
|
||||
}
|
||||
}
|
||||
dns::clear_stale_policies()
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user