CliArgs

Struct CliArgs 

Source
pub struct CliArgs {
Show 17 fields pub state_file: Option<PathBuf>, pub generate_config: Option<PathBuf>, pub loglevel: Option<String>, pub logfile: Option<String>, pub config_file: PathBuf, pub control_ip: Option<String>, pub control_port: Option<u16>, pub control_socket: Option<PathBuf>, pub control_pass: Option<String>, pub retry_limit: Option<u32>, pub one_shot_vanguards: bool, pub disable_vanguards: bool, pub disable_bandguards: bool, pub disable_rendguard: bool, pub disable_logguard: bool, pub enable_cbtverify: bool, pub enable_pathverify: bool,
}
Expand description

Command-line arguments for vanguards-rs.

This struct is used by clap to parse command-line arguments. Arguments override configuration file values, allowing runtime customization without modifying config files.

§Configuration Precedence

Configuration is applied in the following order (later sources override earlier):

  1. Built-in defaults
  2. Configuration file (TOML)
  3. Environment variables (VANGUARDS_STATE, VANGUARDS_CONFIG)
  4. Command-line arguments

§Usage

vanguards-rs [OPTIONS]

§Options

§Connection Options

OptionDescription
--control-ip <IP>IP address of the Tor control port (default: 127.0.0.1)
--control-port <PORT>Tor control port number (typically 9051)
--control-socket <PATH>Path to Tor control socket (e.g., /run/tor/control)
--control-pass <PASS>Tor control port password for authentication

§File Options

OptionDescription
--state <FILE>Path to the vanguard state file [env: VANGUARDS_STATE]
--config <FILE>Path to configuration file [env: VANGUARDS_CONFIG] [default: vanguards.conf]
--generate_config <FILE>Write default config to file and exit

§Logging Options

OptionDescription
--loglevel <LEVEL>Log verbosity: DEBUG, INFO, NOTICE, WARN, ERROR
--logfile <FILE>Log to file instead of stdout (use “:syslog:” for syslog)

§Component Control

OptionDescription
--disable-vanguardsDisable vanguard selection
--disable-bandguardsDisable bandwidth monitoring
--disable-rendguardDisable rendezvous point monitoring
--disable-logguardDisable log monitoring
--enable-cbtverifyEnable circuit build timeout verification
--enable-pathverifyEnable path verification

§Operational Options

OptionDescription
--retry-limit <N>Reconnection attempt limit (default: infinite)
--one-shot-vanguardsSet vanguards and exit immediately

§Help Options

OptionDescription
-h, --helpPrint help (see a summary with ‘-h’)
-V, --versionPrint version

§Examples

Connect to Tor via control port:

vanguards-rs --control-ip 127.0.0.1 --control-port 9051

Connect via Unix socket with password:

vanguards-rs --control-socket /run/tor/control --control-pass mypassword

Generate a default configuration file:

vanguards-rs --generate_config vanguards.conf

Run with custom state file and debug logging:

vanguards-rs --state /var/lib/tor/vanguards.state --loglevel DEBUG

Disable specific components:

vanguards-rs --disable-bandguards --disable-logguard

One-shot mode (set vanguards and exit):

vanguards-rs --one-shot-vanguards

§Environment Variables

  • VANGUARDS_STATE: Path to the vanguard state file (equivalent to --state)
  • VANGUARDS_CONFIG: Path to configuration file (equivalent to --config)

§See Also

  • Config for the full configuration structure
  • load_config for the configuration loading function

Fields§

§state_file: Option<PathBuf>

Path to the vanguard state file.

The state file stores persistent vanguard selections and rendguard statistics. If not specified, defaults to “vanguards.state” in the current directory.

§generate_config: Option<PathBuf>

Write default config to file and exit.

Generates a TOML configuration file with all default values and documentation. Useful for creating a starting point for customization.

§loglevel: Option<String>

Log verbosity (DEBUG, INFO, NOTICE, WARN, ERROR).

Controls the amount of output. DEBUG is most verbose, ERROR is least. Default is NOTICE.

§logfile: Option<String>

Log to file instead of stdout (use “:syslog:” for syslog).

By default, logs go to stdout. Specify a file path to redirect logs, or use the special value “:syslog:” to send logs to the system logger.

§config_file: PathBuf

Path to configuration file.

TOML configuration file containing all settings. Command-line arguments override values from this file.

§control_ip: Option<String>

IP address of the Tor control port.

Can be an IPv4 address, IPv6 address, or hostname (will be resolved). Default is 127.0.0.1.

§control_port: Option<u16>

Tor control port number.

The TCP port where Tor’s control interface is listening. Typically 9051 for the Tor daemon.

§control_socket: Option<PathBuf>

Path to Tor control socket.

Unix domain socket path for Tor control connection. Takes precedence over TCP connection if specified. Common paths: /run/tor/control, /var/run/tor/control

§control_pass: Option<String>

Tor control port password.

Password for HashedControlPassword authentication. If not provided and required, will prompt interactively.

§retry_limit: Option<u32>

Reconnection attempt limit (default: infinite).

Maximum number of times to attempt reconnection to Tor after connection loss. Set to 0 for infinite retries.

§one_shot_vanguards: bool

Set vanguards and exit.

Configure Tor with vanguard settings, save the configuration, and exit immediately. Useful for one-time setup.

§disable_vanguards: bool

Disable vanguard selection.

Prevents vanguards-rs from selecting and configuring vanguard relays. Other monitoring components will still run if enabled.

§disable_bandguards: bool

Disable bandwidth monitoring.

Disables the bandguards component that monitors circuit bandwidth for potential side-channel attacks.

§disable_rendguard: bool

Disable rendezvous point monitoring.

Disables the rendguard component that monitors rendezvous point usage for statistical anomalies.

§disable_logguard: bool

Disable log monitoring.

Disables the logguard component that monitors Tor logs for security-relevant events.

§enable_cbtverify: bool

Enable circuit build timeout verification.

Enables the cbtverify component that monitors circuit construction timing for anomalies. Disabled by default.

§enable_pathverify: bool

Enable path verification.

Enables the pathverify component that verifies circuit paths conform to vanguard configuration. Disabled by default.

Implementations§

Source§

impl CliArgs

Source

pub fn apply_to(&self, config: &mut Config)

Apply CLI arguments to a configuration, overriding values.

Trait Implementations§

Source§

impl Args for CliArgs

Source§

fn group_id() -> Option<Id>

Report the [ArgGroup::id][crate::ArgGroup::id] for this set of arguments
Source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate Self via [FromArgMatches::from_arg_matches_mut] Read more
Source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate self via [FromArgMatches::update_from_arg_matches_mut] Read more
Source§

impl CommandFactory for CliArgs

Source§

fn command<'b>() -> Command

Build a [Command] that can instantiate Self. Read more
Source§

fn command_for_update<'b>() -> Command

Build a [Command] that can update self. Read more
Source§

impl Debug for CliArgs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromArgMatches for CliArgs

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl Parser for CliArgs

§

fn parse() -> Self

Parse from std::env::args_os(), [exit][Error::exit] on error.
§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
§

fn parse_from<I, T>(itr: I) -> Self
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, [exit][Error::exit] on error.
§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
§

fn update_from<I, T>(&mut self, itr: I)
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, [exit][Error::exit] on error. Read more
§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on error.

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.

§

impl<T> Instrument for T

§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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