summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEmīls Piņķis <emils@mullvad.net>2021-01-06 11:48:30 +0000
committerEmīls <emils@mullvad.net>2021-01-11 12:32:09 +0000
commit866fc79a7337611854354fc9e9e54ea9c0817839 (patch)
tree714a6a15cc042422e2357a2a6c6bbe28e4697beb
parent3f3f8b56efd9ed59a1955b128d4e0810298ebf53 (diff)
downloadmullvadvpn-866fc79a7337611854354fc9e9e54ea9c0817839.tar.xz
mullvadvpn-866fc79a7337611854354fc9e9e54ea9c0817839.zip
Add env var to disable offline detection
-rw-r--r--CHANGELOG.md2
-rw-r--r--README.md1
-rw-r--r--talpid-core/src/offline/mod.rs34
3 files changed, 28 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2a0ce87f8..8511aa6851 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,8 @@ Line wrap the file at 100 chars. Th
### Added
- Add header containing OS version to version-check API call to enable OS specific compatibility and
vulnerability checks.
+- Add `TALPID_DISABLE_OFFLINE_MONITOR` environment variable to allow users to disable offline
+ detection.
#### Android
- Allow to configure the tunnel to use custom DNS servers.
diff --git a/README.md b/README.md
index ed6714ef4b..66de0b7329 100644
--- a/README.md
+++ b/README.md
@@ -374,6 +374,7 @@ echo "org.gradle.jvmargs=-Xmx4608M" >> ~/.gradle/gradle.properties
the servers specified on each interface.
* `0`: Only set DNS servers on the tunnel interface. This will misbehave if local custom DNS
servers are used.
+* `TALPID_DISABLE_OFFLINE_MONITOR` - Forces the daemon to always assume the host is online.
## Building and running the desktop Electron GUI app
diff --git a/talpid-core/src/offline/mod.rs b/talpid-core/src/offline/mod.rs
index 9a6ce1dae5..b059d1f216 100644
--- a/talpid-core/src/offline/mod.rs
+++ b/talpid-core/src/offline/mod.rs
@@ -20,13 +20,23 @@ mod imp;
#[path = "android.rs"]
mod imp;
+lazy_static::lazy_static! {
+ /// Disables offline monitor
+ static ref FORCE_DISABLE_OFFLINE_MONITOR: bool = std::env::var("TALPID_DISABLE_OFFLINE_MONITOR")
+ .map(|v| v != "0")
+ .unwrap_or(false);
+}
+
pub use self::imp::Error;
-pub struct MonitorHandle(imp::MonitorHandle);
+pub struct MonitorHandle(Option<imp::MonitorHandle>);
impl MonitorHandle {
pub async fn is_offline(&mut self) -> bool {
- self.0.is_offline().await
+ match self.0.as_mut() {
+ Some(monitor) => monitor.is_offline().await,
+ None => false,
+ }
}
}
@@ -34,12 +44,18 @@ pub async fn spawn_monitor(
sender: Weak<UnboundedSender<TunnelCommand>>,
#[cfg(target_os = "android")] android_context: AndroidContext,
) -> Result<MonitorHandle, Error> {
- Ok(MonitorHandle(
- imp::spawn_monitor(
- sender,
- #[cfg(target_os = "android")]
- android_context,
+ let monitor = if !*FORCE_DISABLE_OFFLINE_MONITOR {
+ Some(
+ imp::spawn_monitor(
+ sender,
+ #[cfg(target_os = "android")]
+ android_context,
+ )
+ .await?,
)
- .await?,
- ))
+ } else {
+ None
+ };
+
+ Ok(MonitorHandle(monitor))
}