--version

This commit is contained in:
Dennis Schwerdel 2015-11-24 11:19:27 +01:00
parent 4e11501b7e
commit 5d006c389c
4 changed files with 16 additions and 2 deletions

View File

@ -27,6 +27,7 @@ use ethernet::SwitchTable;
use ip::RoutingTable; use ip::RoutingTable;
use types::{Error, Mode, Type, Range, Table}; use types::{Error, Mode, Type, Range, Table};
use cloud::{TapCloud, TunCloud}; use cloud::{TapCloud, TunCloud};
use udpmessage::VERSION;
#[cfg(feature = "crypto")] pub use crypto::Crypto; #[cfg(feature = "crypto")] pub use crypto::Crypto;
#[cfg(not(feature = "crypto"))] pub use no_crypto::Crypto; #[cfg(not(feature = "crypto"))] pub use no_crypto::Crypto;
@ -65,7 +66,8 @@ struct Args {
flag_verbose: bool, flag_verbose: bool,
flag_quiet: bool, flag_quiet: bool,
flag_ifup: Option<String>, flag_ifup: Option<String>,
flag_ifdown: Option<String> flag_ifdown: Option<String>,
flag_version: bool
} }
fn run_script(script: String, ifname: &str) { fn run_script(script: String, ifname: &str) {
@ -83,6 +85,13 @@ fn run_script(script: String, ifname: &str) {
fn main() { fn main() {
let args: Args = Docopt::new(USAGE).and_then(|d| d.decode()).unwrap_or_else(|e| e.exit()); 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| { log::set_logger(|max_log_level| {
assert!(!args.flag_verbose || !args.flag_quiet); assert!(!args.flag_verbose || !args.flag_quiet);
if args.flag_verbose { if args.flag_verbose {

View File

@ -7,7 +7,7 @@ use super::util::{as_obj, as_bytes, to_vec};
use super::Crypto; use super::Crypto;
const MAGIC: [u8; 3] = [0x76, 0x70, 0x6e]; const MAGIC: [u8; 3] = [0x76, 0x70, 0x6e];
const VERSION: u8 = 1; pub const VERSION: u8 = 1;
#[repr(packed)] #[repr(packed)]
struct TopHeader { struct TopHeader {

View File

@ -23,3 +23,4 @@ Options:
-v, --verbose Print debug information. -v, --verbose Print debug information.
-q, --quiet Only print errors and warnings. -q, --quiet Only print errors and warnings.
-h, --help Display the help. -h, --help Display the help.
-V, --version Print the version and exit.

View File

@ -92,6 +92,10 @@ vpncloud(1) -- Peer-to-peer VPN
Display the help. Display the help.
* `-V`, `--version`:
Print the version and exit.
## DESCRIPTION ## DESCRIPTION