pub fn connection_sequence(bytecount_interval: u32) -> Vec<OvpnCommand>Expand description
The standard startup sequence that most management clients send after connecting.
This is the pattern used by node-openvpn and other clients: enable
log streaming, request the PID, start byte-count notifications, and
release the hold so OpenVPN begins connecting.
§Arguments
bytecount_interval— seconds between>BYTECOUNT:notifications (pass0to skip enabling byte counts).
§Examples
use openvpn_mgmt_codec::command::connection_sequence;
use openvpn_mgmt_codec::OvpnCommand;
let cmds = connection_sequence(5);
assert!(cmds.iter().any(|c| matches!(c, OvpnCommand::HoldRelease)));To send these over a framed connection:
use tokio::net::TcpStream;
use tokio_util::codec::Framed;
use futures::SinkExt;
use openvpn_mgmt_codec::{OvpnCodec, OvpnCommand};
use openvpn_mgmt_codec::command::connection_sequence;
let stream = TcpStream::connect("127.0.0.1:7505").await?;
let mut framed = Framed::new(stream, OvpnCodec::new());
for cmd in connection_sequence(5) {
framed.send(cmd).await?;
}