killswitch in session
This commit is contained in:
+4
-2
@@ -41,6 +41,7 @@ pub struct VpnTrafficStats {
|
||||
pub struct Session {
|
||||
pub(crate) cancel_token: CancellationToken,
|
||||
pub(crate) proxy_ip: String,
|
||||
pub(crate) killswitch_enabled: bool,
|
||||
}
|
||||
|
||||
#[uniffi::export]
|
||||
@@ -48,7 +49,7 @@ impl Session {
|
||||
pub fn stop(&self) {
|
||||
info!("Stopping session...");
|
||||
self.cancel_token.cancel();
|
||||
let _ = reset_platform_routing(Some(&self.proxy_ip));
|
||||
let _ = reset_platform_routing(Some(&self.proxy_ip), &self.killswitch_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +57,7 @@ impl Drop for Session {
|
||||
fn drop(&mut self) {
|
||||
info!("Session dropped, stopping all tasks...");
|
||||
self.cancel_token.cancel();
|
||||
let _ = reset_platform_routing(Some(&self.proxy_ip));
|
||||
let _ = reset_platform_routing(Some(&self.proxy_ip), &self.killswitch_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +166,7 @@ impl SessionManager {
|
||||
Arc::new(Session {
|
||||
cancel_token: session_token,
|
||||
proxy_ip: remote_proxy_ip,
|
||||
killswitch_enabled: killswitch_enabled,
|
||||
})
|
||||
}
|
||||
pub fn get_traffic_stats(&self) -> VpnTrafficStats {
|
||||
|
||||
@@ -207,7 +207,7 @@ pub fn setup_platform_routing(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn reset_platform_routing(_proxy_ip: Option<&str>) -> io::Result<()> {
|
||||
pub fn reset_platform_routing(_proxy_ip: Option<&str>, _was_killswitch: &bool) -> io::Result<()> {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let _ = run_cmd_ext("ip link delete netr0", true);
|
||||
@@ -231,7 +231,7 @@ pub fn reset_platform_routing(_proxy_ip: Option<&str>) -> io::Result<()> {
|
||||
true,
|
||||
);
|
||||
|
||||
if was_killswitch {
|
||||
if _was_killswitch {
|
||||
netrunner_logger::info!(
|
||||
"Restoring physical default route (DHCP renew needed or manual restore)"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user