pub struct ManagementClient<T> { /* private fields */ }Expand description
A high-level client for the OpenVPN management interface.
See the module documentation for usage examples.
Implementations§
Source§impl<T> ManagementClient<T>
impl<T> ManagementClient<T>
Sourcepub fn new(
framed: Framed<T, OvpnCodec>,
notification_tx: Sender<Notification>,
) -> Self
pub fn new( framed: Framed<T, OvpnCodec>, notification_tx: Sender<Notification>, ) -> Self
Wrap a framed transport with an existing broadcast sender for notification dispatch.
The caller creates the broadcast::channel and passes the sender
here. This gives full control over channel capacity and lifetime.
Call broadcast::Sender::subscribe on your copy of the sender to
create receivers — multiple independent subscribers are supported.
Sourcepub fn into_framed(self) -> Framed<T, OvpnCodec>
pub fn into_framed(self) -> Framed<T, OvpnCodec>
Recover the underlying framed transport.
Sourcepub async fn status_raw(
&mut self,
format: StatusFormat,
) -> Result<Vec<String>, ClientError>
pub async fn status_raw( &mut self, format: StatusFormat, ) -> Result<Vec<String>, ClientError>
Query the connection status in the given format.
Returns the raw multi-line response. Use status
for a typed result.
Sourcepub async fn status(
&mut self,
format: StatusFormat,
) -> Result<StatusResponse, ClientError>
pub async fn status( &mut self, format: StatusFormat, ) -> Result<StatusResponse, ClientError>
Query and parse the server-mode connection status.
Sourcepub async fn client_statistics(
&mut self,
format: StatusFormat,
) -> Result<ClientStatistics, ClientError>
pub async fn client_statistics( &mut self, format: StatusFormat, ) -> Result<ClientStatistics, ClientError>
Query and parse client-mode statistics.
Sourcepub async fn state(&mut self) -> Result<Vec<StateEntry>, ClientError>
pub async fn state(&mut self) -> Result<Vec<StateEntry>, ClientError>
Query the current state as a multi-line history.
Sourcepub async fn current_state(&mut self) -> Result<StateEntry, ClientError>
pub async fn current_state(&mut self) -> Result<StateEntry, ClientError>
Query the most recent state entry.
Sourcepub async fn state_stream(
&mut self,
mode: StreamMode,
) -> Result<Option<Vec<StateEntry>>, ClientError>
pub async fn state_stream( &mut self, mode: StreamMode, ) -> Result<Option<Vec<StateEntry>>, ClientError>
Control real-time state notifications.
Streaming modes (All, OnAll, Recent) return accumulated history
lines. On/Off return Ok(None).
Sourcepub async fn version(&mut self) -> Result<VersionInfo, ClientError>
pub async fn version(&mut self) -> Result<VersionInfo, ClientError>
Query the OpenVPN and management interface version.
Sourcepub async fn set_version(&mut self, version: u32) -> Result<(), ClientError>
pub async fn set_version(&mut self, version: u32) -> Result<(), ClientError>
Set the management client version to announce feature support.
For versions < 4 this produces no response from the server.
For versions >= 4 a SUCCESS: response is expected.
Sourcepub async fn pid(&mut self) -> Result<u32, ClientError>
pub async fn pid(&mut self) -> Result<u32, ClientError>
Query the PID of the OpenVPN process.
Sourcepub async fn help(&mut self) -> Result<Vec<String>, ClientError>
pub async fn help(&mut self) -> Result<Vec<String>, ClientError>
List available management commands.
Sourcepub async fn verb(&mut self, level: Option<u8>) -> Result<String, ClientError>
pub async fn verb(&mut self, level: Option<u8>) -> Result<String, ClientError>
Query or set the log verbosity level.
Sourcepub async fn mute(
&mut self,
threshold: Option<u32>,
) -> Result<String, ClientError>
pub async fn mute( &mut self, threshold: Option<u32>, ) -> Result<String, ClientError>
Query or set the mute threshold.
Sourcepub async fn net(&mut self) -> Result<Vec<String>, ClientError>
pub async fn net(&mut self) -> Result<Vec<String>, ClientError>
(Windows) Show network adapter list.
Sourcepub async fn log(
&mut self,
mode: StreamMode,
) -> Result<Option<Vec<String>>, ClientError>
pub async fn log( &mut self, mode: StreamMode, ) -> Result<Option<Vec<String>>, ClientError>
Control real-time log streaming.
Streaming modes return accumulated log history. On/Off return Ok(None).
Sourcepub async fn echo(
&mut self,
mode: StreamMode,
) -> Result<Option<Vec<String>>, ClientError>
pub async fn echo( &mut self, mode: StreamMode, ) -> Result<Option<Vec<String>>, ClientError>
Control real-time echo notifications.
Sourcepub async fn bytecount(&mut self, interval: u32) -> Result<(), ClientError>
pub async fn bytecount(&mut self, interval: u32) -> Result<(), ClientError>
Enable or disable byte count notifications at N-second intervals. Pass 0 to disable.
Sourcepub async fn signal(&mut self, signal: Signal) -> Result<(), ClientError>
pub async fn signal(&mut self, signal: Signal) -> Result<(), ClientError>
Send a signal to the OpenVPN daemon.
Sourcepub async fn kill(&mut self, target: KillTarget) -> Result<(), ClientError>
pub async fn kill(&mut self, target: KillTarget) -> Result<(), ClientError>
Kill a specific client connection (server mode).
Sourcepub async fn hold_query(&mut self) -> Result<bool, ClientError>
pub async fn hold_query(&mut self) -> Result<bool, ClientError>
Query the current hold flag.
Sourcepub async fn hold_on(&mut self) -> Result<(), ClientError>
pub async fn hold_on(&mut self) -> Result<(), ClientError>
Set the hold flag on.
Sourcepub async fn hold_off(&mut self) -> Result<(), ClientError>
pub async fn hold_off(&mut self) -> Result<(), ClientError>
Clear the hold flag.
Sourcepub async fn hold_release(&mut self) -> Result<(), ClientError>
pub async fn hold_release(&mut self) -> Result<(), ClientError>
Release from hold state and start OpenVPN.
Sourcepub async fn username(
&mut self,
auth_type: AuthType,
value: impl Into<String>,
) -> Result<(), ClientError>
pub async fn username( &mut self, auth_type: AuthType, value: impl Into<String>, ) -> Result<(), ClientError>
Supply a username for the given auth type.
Sourcepub async fn password(
&mut self,
auth_type: AuthType,
value: impl Into<String>,
) -> Result<(), ClientError>
pub async fn password( &mut self, auth_type: AuthType, value: impl Into<String>, ) -> Result<(), ClientError>
Supply a password for the given auth type.
Sourcepub async fn auth_retry(
&mut self,
mode: AuthRetryMode,
) -> Result<(), ClientError>
pub async fn auth_retry( &mut self, mode: AuthRetryMode, ) -> Result<(), ClientError>
Set the auth-retry strategy.
Sourcepub async fn forget_passwords(&mut self) -> Result<(), ClientError>
pub async fn forget_passwords(&mut self) -> Result<(), ClientError>
Forget all passwords entered during this management session.
Sourcepub async fn challenge_response(
&mut self,
state_id: impl Into<String>,
response: impl Into<String>,
) -> Result<(), ClientError>
pub async fn challenge_response( &mut self, state_id: impl Into<String>, response: impl Into<String>, ) -> Result<(), ClientError>
Respond to a CRV1 dynamic challenge.
Sourcepub async fn static_challenge_response(
&mut self,
password_b64: impl Into<String>,
response_b64: impl Into<String>,
) -> Result<(), ClientError>
pub async fn static_challenge_response( &mut self, password_b64: impl Into<String>, response_b64: impl Into<String>, ) -> Result<(), ClientError>
Respond to a static challenge.
Sourcepub async fn cr_response(
&mut self,
response: impl Into<String>,
) -> Result<(), ClientError>
pub async fn cr_response( &mut self, response: impl Into<String>, ) -> Result<(), ClientError>
Respond to a CR_TEXT challenge.
Sourcepub async fn need_ok(
&mut self,
name: impl Into<String>,
response: NeedOkResponse,
) -> Result<(), ClientError>
pub async fn need_ok( &mut self, name: impl Into<String>, response: NeedOkResponse, ) -> Result<(), ClientError>
Respond to a >NEED-OK: prompt.
Sourcepub async fn need_str(
&mut self,
name: impl Into<String>,
value: impl Into<String>,
) -> Result<(), ClientError>
pub async fn need_str( &mut self, name: impl Into<String>, value: impl Into<String>, ) -> Result<(), ClientError>
Respond to a >NEED-STR: prompt.
Sourcepub async fn pkcs11_id_count(&mut self) -> Result<String, ClientError>
pub async fn pkcs11_id_count(&mut self) -> Result<String, ClientError>
Query available PKCS#11 certificate count.
Sourcepub async fn pkcs11_id_get(&mut self, index: u32) -> Result<String, ClientError>
pub async fn pkcs11_id_get(&mut self, index: u32) -> Result<String, ClientError>
Retrieve a PKCS#11 certificate by index.
Sourcepub async fn rsa_sig(
&mut self,
base64_lines: Vec<String>,
) -> Result<(), ClientError>
pub async fn rsa_sig( &mut self, base64_lines: Vec<String>, ) -> Result<(), ClientError>
Provide an RSA signature in response to >RSA_SIGN:.
Sourcepub async fn pk_sig(
&mut self,
base64_lines: Vec<String>,
) -> Result<(), ClientError>
pub async fn pk_sig( &mut self, base64_lines: Vec<String>, ) -> Result<(), ClientError>
Provide a signature in response to >PK_SIGN:.
Sourcepub async fn certificate(
&mut self,
pem_lines: Vec<String>,
) -> Result<(), ClientError>
pub async fn certificate( &mut self, pem_lines: Vec<String>, ) -> Result<(), ClientError>
Supply an external certificate in response to >NEED-CERTIFICATE:.
Sourcepub async fn client_auth(
&mut self,
cid: u64,
kid: u64,
config_lines: Vec<String>,
) -> Result<(), ClientError>
pub async fn client_auth( &mut self, cid: u64, kid: u64, config_lines: Vec<String>, ) -> Result<(), ClientError>
Authorize a client and push config directives.
Sourcepub async fn client_auth_nt(
&mut self,
cid: u64,
kid: u64,
) -> Result<(), ClientError>
pub async fn client_auth_nt( &mut self, cid: u64, kid: u64, ) -> Result<(), ClientError>
Authorize a client without pushing any config.
Sourcepub async fn client_deny(&mut self, deny: ClientDeny) -> Result<(), ClientError>
pub async fn client_deny(&mut self, deny: ClientDeny) -> Result<(), ClientError>
Deny a client connection.
Sourcepub async fn client_kill(
&mut self,
cid: u64,
message: Option<String>,
) -> Result<(), ClientError>
pub async fn client_kill( &mut self, cid: u64, message: Option<String>, ) -> Result<(), ClientError>
Kill a client session by CID.
Sourcepub async fn client_pending_auth(
&mut self,
cid: u64,
kid: u64,
extra: impl Into<String>,
timeout: u32,
) -> Result<(), ClientError>
pub async fn client_pending_auth( &mut self, cid: u64, kid: u64, extra: impl Into<String>, timeout: u32, ) -> Result<(), ClientError>
Defer authentication for a client.
Sourcepub async fn remote(&mut self, action: RemoteAction) -> Result<(), ClientError>
pub async fn remote(&mut self, action: RemoteAction) -> Result<(), ClientError>
Respond to a >REMOTE: notification.
Sourcepub async fn proxy(&mut self, action: ProxyAction) -> Result<(), ClientError>
pub async fn proxy(&mut self, action: ProxyAction) -> Result<(), ClientError>
Respond to a >PROXY: notification.
Sourcepub async fn load_stats(&mut self) -> Result<LoadStats, ClientError>
pub async fn load_stats(&mut self) -> Result<LoadStats, ClientError>
Request aggregated server stats.
Sourcepub async fn env_filter(&mut self, level: u32) -> Result<(), ClientError>
pub async fn env_filter(&mut self, level: u32) -> Result<(), ClientError>
Set the env-var filter level for >CLIENT:ENV blocks.
Sourcepub async fn remote_entry_count(&mut self) -> Result<Vec<String>, ClientError>
pub async fn remote_entry_count(&mut self) -> Result<Vec<String>, ClientError>
Query the number of --remote entries.
Sourcepub async fn remote_entry_get(
&mut self,
range: RemoteEntryRange,
) -> Result<Vec<String>, ClientError>
pub async fn remote_entry_get( &mut self, range: RemoteEntryRange, ) -> Result<Vec<String>, ClientError>
Retrieve --remote entries.
Sourcepub async fn push_update_broad(
&mut self,
options: impl Into<String>,
) -> Result<(), ClientError>
pub async fn push_update_broad( &mut self, options: impl Into<String>, ) -> Result<(), ClientError>
Broadcast a push option update to all connected clients.
Sourcepub async fn push_update_cid(
&mut self,
cid: u64,
options: impl Into<String>,
) -> Result<(), ClientError>
pub async fn push_update_cid( &mut self, cid: u64, options: impl Into<String>, ) -> Result<(), ClientError>
Push an option update to a specific client.
Sourcepub async fn management_password(
&mut self,
password: impl Into<String>,
) -> Result<(), ClientError>
pub async fn management_password( &mut self, password: impl Into<String>, ) -> Result<(), ClientError>
Authenticate to the management interface.
Sourcepub async fn exit(self) -> Result<(), ClientError>
pub async fn exit(self) -> Result<(), ClientError>
Close the management session. Consumes the client since the connection is no longer usable.
Sourcepub async fn raw(
&mut self,
command: impl Into<String>,
) -> Result<String, ClientError>
pub async fn raw( &mut self, command: impl Into<String>, ) -> Result<String, ClientError>
Send a raw command expecting SUCCESS:/ERROR:.
Sourcepub async fn raw_multi_line(
&mut self,
command: impl Into<String>,
) -> Result<Vec<String>, ClientError>
pub async fn raw_multi_line( &mut self, command: impl Into<String>, ) -> Result<Vec<String>, ClientError>
Send a raw command expecting a multi-line response.