diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-04-19 18:55:31 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-04-23 21:51:59 +0200 |
| commit | 308832d0df052dd4433bda2cc5c586ca9745c249 (patch) | |
| tree | fb923fc7a264149837fe36d442b920bed8874a48 /talpid-core | |
| parent | 8f6f61ebd6a013f657a2523dbe4b4cfa1a1cb462 (diff) | |
| download | mullvadvpn-308832d0df052dd4433bda2cc5c586ca9745c249.tar.xz mullvadvpn-308832d0df052dd4433bda2cc5c586ca9745c249.zip | |
Add basic windows service
Diffstat (limited to 'talpid-core')
| -rw-r--r-- | talpid-core/Cargo.toml | 1 | ||||
| -rw-r--r-- | talpid-core/src/lib.rs | 1 | ||||
| -rw-r--r-- | talpid-core/src/process/openvpn.rs | 19 |
3 files changed, 20 insertions, 1 deletions
diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml index addb9f61d7..c9e4da653c 100644 --- a/talpid-core/Cargo.toml +++ b/talpid-core/Cargo.toml @@ -6,6 +6,7 @@ description = "Privacy preserving and secure VPN client library" license = "GPL-3.0" [dependencies] +atty = "0.2" duct = "0.10" error-chain = "0.11" jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc", tag = "v8.0.1" } diff --git a/talpid-core/src/lib.rs b/talpid-core/src/lib.rs index fc85584267..6c6e907255 100644 --- a/talpid-core/src/lib.rs +++ b/talpid-core/src/lib.rs @@ -10,6 +10,7 @@ //! GNU General Public License as published by the Free Software Foundation, either version 3 of //! the License, or (at your option) any later version. +extern crate atty; extern crate duct; #[macro_use] diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs index f315e86eb5..734918853f 100644 --- a/talpid-core/src/process/openvpn.rs +++ b/talpid-core/src/process/openvpn.rs @@ -1,3 +1,4 @@ +use atty; use duct; use std::ffi::{OsStr, OsString}; @@ -106,7 +107,23 @@ impl OpenVpnCommand { /// Build a runnable expression from the current state of the command. pub fn build(&self) -> duct::Expression { debug!("Building expression: {}", &self); - duct::cmd(&self.openvpn_bin, self.get_arguments()).unchecked() + + let mut cmd = duct::cmd(&self.openvpn_bin, self.get_arguments()).unchecked(); + + // Prevent forwarding the stdio when it's not available. + if atty::is(atty::Stream::Stdin) { + cmd = cmd.stdin_null(); + } + + if atty::is(atty::Stream::Stdout) { + cmd = cmd.stdout_null(); + } + + if atty::is(atty::Stream::Stderr) { + cmd = cmd.stderr_null(); + } + + cmd } /// Sets extra options |
