Skip to main content

ManagementClient

Struct ManagementClient 

Source
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>
where T: AsyncRead + AsyncWrite + Unpin,

Source

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.

Source

pub fn into_framed(self) -> Framed<T, OvpnCodec>

Recover the underlying framed transport.

Source

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.

Source

pub async fn status( &mut self, format: StatusFormat, ) -> Result<StatusResponse, ClientError>

Query and parse the server-mode connection status.

Source

pub async fn client_statistics( &mut self, format: StatusFormat, ) -> Result<ClientStatistics, ClientError>

Query and parse client-mode statistics.

Source

pub async fn state(&mut self) -> Result<Vec<StateEntry>, ClientError>

Query the current state as a multi-line history.

Source

pub async fn current_state(&mut self) -> Result<StateEntry, ClientError>

Query the most recent state entry.

Source

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).

Source

pub async fn version(&mut self) -> Result<VersionInfo, ClientError>

Query the OpenVPN and management interface version.

Source

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.

Source

pub async fn pid(&mut self) -> Result<u32, ClientError>

Query the PID of the OpenVPN process.

Source

pub async fn help(&mut self) -> Result<Vec<String>, ClientError>

List available management commands.

Source

pub async fn verb(&mut self, level: Option<u8>) -> Result<String, ClientError>

Query or set the log verbosity level.

Source

pub async fn mute( &mut self, threshold: Option<u32>, ) -> Result<String, ClientError>

Query or set the mute threshold.

Source

pub async fn net(&mut self) -> Result<Vec<String>, ClientError>

(Windows) Show network adapter list.

Source

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).

Source

pub async fn echo( &mut self, mode: StreamMode, ) -> Result<Option<Vec<String>>, ClientError>

Control real-time echo notifications.

Source

pub async fn bytecount(&mut self, interval: u32) -> Result<(), ClientError>

Enable or disable byte count notifications at N-second intervals. Pass 0 to disable.

Source

pub async fn signal(&mut self, signal: Signal) -> Result<(), ClientError>

Send a signal to the OpenVPN daemon.

Source

pub async fn kill(&mut self, target: KillTarget) -> Result<(), ClientError>

Kill a specific client connection (server mode).

Source

pub async fn hold_query(&mut self) -> Result<bool, ClientError>

Query the current hold flag.

Source

pub async fn hold_on(&mut self) -> Result<(), ClientError>

Set the hold flag on.

Source

pub async fn hold_off(&mut self) -> Result<(), ClientError>

Clear the hold flag.

Source

pub async fn hold_release(&mut self) -> Result<(), ClientError>

Release from hold state and start OpenVPN.

Source

pub async fn username( &mut self, auth_type: AuthType, value: impl Into<String>, ) -> Result<(), ClientError>

Supply a username for the given auth type.

Source

pub async fn password( &mut self, auth_type: AuthType, value: impl Into<String>, ) -> Result<(), ClientError>

Supply a password for the given auth type.

Source

pub async fn auth_retry( &mut self, mode: AuthRetryMode, ) -> Result<(), ClientError>

Set the auth-retry strategy.

Source

pub async fn forget_passwords(&mut self) -> Result<(), ClientError>

Forget all passwords entered during this management session.

Source

pub async fn challenge_response( &mut self, state_id: impl Into<String>, response: impl Into<String>, ) -> Result<(), ClientError>

Respond to a CRV1 dynamic challenge.

Source

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.

Source

pub async fn cr_response( &mut self, response: impl Into<String>, ) -> Result<(), ClientError>

Respond to a CR_TEXT challenge.

Source

pub async fn need_ok( &mut self, name: impl Into<String>, response: NeedOkResponse, ) -> Result<(), ClientError>

Respond to a >NEED-OK: prompt.

Source

pub async fn need_str( &mut self, name: impl Into<String>, value: impl Into<String>, ) -> Result<(), ClientError>

Respond to a >NEED-STR: prompt.

Source

pub async fn pkcs11_id_count(&mut self) -> Result<String, ClientError>

Query available PKCS#11 certificate count.

Source

pub async fn pkcs11_id_get(&mut self, index: u32) -> Result<String, ClientError>

Retrieve a PKCS#11 certificate by index.

Source

pub async fn rsa_sig( &mut self, base64_lines: Vec<String>, ) -> Result<(), ClientError>

Provide an RSA signature in response to >RSA_SIGN:.

Source

pub async fn pk_sig( &mut self, base64_lines: Vec<String>, ) -> Result<(), ClientError>

Provide a signature in response to >PK_SIGN:.

Source

pub async fn certificate( &mut self, pem_lines: Vec<String>, ) -> Result<(), ClientError>

Supply an external certificate in response to >NEED-CERTIFICATE:.

Source

pub async fn client_auth( &mut self, cid: u64, kid: u64, config_lines: Vec<String>, ) -> Result<(), ClientError>

Authorize a client and push config directives.

Source

pub async fn client_auth_nt( &mut self, cid: u64, kid: u64, ) -> Result<(), ClientError>

Authorize a client without pushing any config.

Source

pub async fn client_deny(&mut self, deny: ClientDeny) -> Result<(), ClientError>

Deny a client connection.

Source

pub async fn client_kill( &mut self, cid: u64, message: Option<String>, ) -> Result<(), ClientError>

Kill a client session by CID.

Source

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.

Source

pub async fn remote(&mut self, action: RemoteAction) -> Result<(), ClientError>

Respond to a >REMOTE: notification.

Source

pub async fn proxy(&mut self, action: ProxyAction) -> Result<(), ClientError>

Respond to a >PROXY: notification.

Source

pub async fn load_stats(&mut self) -> Result<LoadStats, ClientError>

Request aggregated server stats.

Source

pub async fn env_filter(&mut self, level: u32) -> Result<(), ClientError>

Set the env-var filter level for >CLIENT:ENV blocks.

Source

pub async fn remote_entry_count(&mut self) -> Result<Vec<String>, ClientError>

Query the number of --remote entries.

Source

pub async fn remote_entry_get( &mut self, range: RemoteEntryRange, ) -> Result<Vec<String>, ClientError>

Retrieve --remote entries.

Source

pub async fn push_update_broad( &mut self, options: impl Into<String>, ) -> Result<(), ClientError>

Broadcast a push option update to all connected clients.

Source

pub async fn push_update_cid( &mut self, cid: u64, options: impl Into<String>, ) -> Result<(), ClientError>

Push an option update to a specific client.

Source

pub async fn management_password( &mut self, password: impl Into<String>, ) -> Result<(), ClientError>

Authenticate to the management interface.

Source

pub async fn exit(self) -> Result<(), ClientError>

Close the management session. Consumes the client since the connection is no longer usable.

Source

pub async fn raw( &mut self, command: impl Into<String>, ) -> Result<String, ClientError>

Send a raw command expecting SUCCESS:/ERROR:.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more