From 5d006c389c29bdb33eb16ced3989d30b81a97bc5 Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Tue, 24 Nov 2015 11:19:27 +0100 Subject: [PATCH] --version --- src/main.rs | 11 ++++++++++- src/udpmessage.rs | 2 +- src/usage.txt | 1 + vpncloud.md | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4ee58b1..9b9945e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,7 @@ use ethernet::SwitchTable; use ip::RoutingTable; use types::{Error, Mode, Type, Range, Table}; use cloud::{TapCloud, TunCloud}; +use udpmessage::VERSION; #[cfg(feature = "crypto")] pub use crypto::Crypto; #[cfg(not(feature = "crypto"))] pub use no_crypto::Crypto; @@ -65,7 +66,8 @@ struct Args { flag_verbose: bool, flag_quiet: bool, flag_ifup: Option, - flag_ifdown: Option + flag_ifdown: Option, + flag_version: bool } fn run_script(script: String, ifname: &str) { @@ -83,6 +85,13 @@ fn run_script(script: String, ifname: &str) { fn main() { let args: Args = Docopt::new(USAGE).and_then(|d| d.decode()).unwrap_or_else(|e| e.exit()); + if args.flag_version { + println!("VpnCloud v{} ({}, protocol version {})", env!("CARGO_PKG_VERSION"), + if cfg!(feature = "crypto") { "with crypto support" } else { "without crypto support" }, + VERSION + ); + return; + } log::set_logger(|max_log_level| { assert!(!args.flag_verbose || !args.flag_quiet); if args.flag_verbose { diff --git a/src/udpmessage.rs b/src/udpmessage.rs index 0c65a40..1598304 100644 --- a/src/udpmessage.rs +++ b/src/udpmessage.rs @@ -7,7 +7,7 @@ use super::util::{as_obj, as_bytes, to_vec}; use super::Crypto; const MAGIC: [u8; 3] = [0x76, 0x70, 0x6e]; -const VERSION: u8 = 1; +pub const VERSION: u8 = 1; #[repr(packed)] struct TopHeader { diff --git a/src/usage.txt b/src/usage.txt index 870ccfb..115eb34 100644 --- a/src/usage.txt +++ b/src/usage.txt @@ -23,3 +23,4 @@ Options: -v, --verbose Print debug information. -q, --quiet Only print errors and warnings. -h, --help Display the help. + -V, --version Print the version and exit. diff --git a/vpncloud.md b/vpncloud.md index 3964e4c..3051f82 100644 --- a/vpncloud.md +++ b/vpncloud.md @@ -92,6 +92,10 @@ vpncloud(1) -- Peer-to-peer VPN Display the help. + * `-V`, `--version`: + + Print the version and exit. + ## DESCRIPTION