summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2017-06-27 16:37:04 +0200
committerLinus Färnstrand <linus@mullvad.net>2017-06-30 15:58:39 +0200
commitfd2935c046925b169dd268918e8b594d5cd8e278 (patch)
tree79f8085bb65274931ccfb5deaf520eef8b714b1b
parent39e704f76cd74f1700db2efe7622110d52f82951 (diff)
downloadmullvadvpn-fd2935c046925b169dd268918e8b594d5cd8e278.tar.xz
mullvadvpn-fd2935c046925b169dd268918e8b594d5cd8e278.zip
Add user-pass-auth argument to OpenVpnCommand
-rw-r--r--talpid_core/src/process/openvpn.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/talpid_core/src/process/openvpn.rs b/talpid_core/src/process/openvpn.rs
index ba6688b034..09e845b640 100644
--- a/talpid_core/src/process/openvpn.rs
+++ b/talpid_core/src/process/openvpn.rs
@@ -35,6 +35,7 @@ pub struct OpenVpnCommand {
openvpn_bin: OsString,
config: Option<PathBuf>,
remote: Option<net::Endpoint>,
+ user_pass_path: Option<PathBuf>,
plugin: Option<(PathBuf, Vec<String>)>,
}
@@ -46,6 +47,7 @@ impl OpenVpnCommand {
openvpn_bin: OsString::from(openvpn_bin.as_ref()),
config: None,
remote: None,
+ user_pass_path: None,
plugin: None,
}
}
@@ -62,6 +64,13 @@ impl OpenVpnCommand {
self
}
+ /// Sets the path to the file where the username and password for user-pass authentication is
+ /// stored. See the `--auth-user-pass` OpenVPN documentation for details.
+ pub fn user_pass<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
+ self.user_pass_path = Some(path.as_ref().to_path_buf());
+ self
+ }
+
/// Sets a plugin and its arguments that OpenVPN will be started with.
pub fn plugin<P: AsRef<Path>>(&mut self, path: P, args: Vec<String>) -> &mut Self {
self.plugin = Some((path.as_ref().to_path_buf(), args));
@@ -84,6 +93,7 @@ impl OpenVpnCommand {
}
args.extend(self.remote_arguments().iter().map(OsString::from));
+ args.extend(self.authentication_arguments());
if let Some((ref path, ref plugin_args)) = self.plugin {
args.push(OsString::from("--plugin"));
@@ -129,6 +139,15 @@ impl OpenVpnCommand {
}
args
}
+
+ fn authentication_arguments(&self) -> Vec<OsString> {
+ let mut args = vec![];
+ if let Some(ref user_pass_path) = self.user_pass_path {
+ args.push(OsString::from("--auth-user-pass"));
+ args.push(OsString::from(user_pass_path));
+ }
+ args
+ }
}
impl fmt::Display for OpenVpnCommand {