pub struct VersionInfo { /* private fields */ }Expand description
Parsed output from the version command’s multi-line response.
The response from OpenVPN looks like:
OpenVPN Version: OpenVPN 2.6.9 x86_64-pc-linux-gnu [SSL (OpenSSL)] ...
Management Interface Version: 5
ENDNote: OpenVPN ≥ 2.6.16 shortened the header to Management Version: 5
(without “Interface”). Both forms are accepted.
This struct extracts the management interface version (which is the field most consumers need for feature-gating) and keeps the raw lines for anything else.
§Examples
use openvpn_mgmt_codec::VersionInfo;
let lines = vec![
"OpenVPN Version: OpenVPN 2.6.9 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD]".to_string(),
"Management Interface Version: 5".to_string(),
];
let info = VersionInfo::parse(&lines);
assert_eq!(info.management_version(), Some(5));
assert!(info.openvpn_version_line().unwrap().contains("2.6.9"));Implementations§
Source§impl VersionInfo
impl VersionInfo
Sourcepub fn parse(lines: &[String]) -> Self
pub fn parse(lines: &[String]) -> Self
Parse a version command’s multi-line response into structured data.
Lines that don’t match known prefixes are preserved in
raw_lines for forward compatibility.
Sourcepub fn management_version(&self) -> Option<u32>
pub fn management_version(&self) -> Option<u32>
The management interface protocol version (e.g. 5).
Returns None if the line was missing or unparseable. Use this to
gate features: for instance, client-pending-auth requires
management version >= 5 (OpenVPN 2.5+).
Sourcepub fn openvpn_version_line(&self) -> Option<&str>
pub fn openvpn_version_line(&self) -> Option<&str>
The full OpenVPN Version: line (e.g. "OpenVPN Version: OpenVPN 2.6.9 ...").
Trait Implementations§
Source§impl Clone for VersionInfo
impl Clone for VersionInfo
Source§fn clone(&self) -> VersionInfo
fn clone(&self) -> VersionInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more