diff options
| -rw-r--r-- | talpid_core/src/process/openvpn.rs | 19 |
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 { |
