Skip to main content

server_connection_sequence

Function server_connection_sequence 

Source
pub fn server_connection_sequence(
    bytecount_interval: u32,
    env_filter: u32,
) -> Vec<OvpnCommand>
Expand description

Standard startup sequence for server-mode management clients.

Returns the commands that a management program typically sends when OpenVPN connects with --management-client. This covers the same basics as connection_sequence (log/state streaming, PID, bytecount, hold release) and additionally sets the >CLIENT:ENV filter level so that client notifications include the desired set of environment variables.

§Arguments

  • bytecount_interval — seconds between >BYTECOUNT_CLI: notifications (0 to disable).
  • env_filter — ENV filter level for >CLIENT:ENV blocks. Level 0 sends all variables; higher levels progressively filter.

§Example

use openvpn_mgmt_codec::command::server_connection_sequence;
use openvpn_mgmt_codec::OvpnCommand;

let cmds = server_connection_sequence(5, 0);

// Contains env-filter for server-mode client notifications.
assert!(cmds.iter().any(|cmd| matches!(cmd, OvpnCommand::EnvFilter(0))));
assert!(cmds.iter().any(|cmd| matches!(cmd, OvpnCommand::HoldRelease)));