From: Ian Jackson Date: Tue, 10 Jan 2023 00:41:17 +0000 (+0000) Subject: Config inspection: Support link names on client X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=b0c677da7cb9b4612e6233595dab686e2c4a7e24;p=hippotat.git Config inspection: Support link names on client Signed-off-by: Ian Jackson --- diff --git a/client/client.rs b/client/client.rs index 96476c8..c1acdd2 100644 --- a/client/client.rs +++ b/client/client.rs @@ -21,7 +21,11 @@ pub struct Opts { /// Print a config item, do not actually run /// - /// One line is output for each association + /// One line is output for each association. + /// Additional pseudo-config-keys are recognised: + /// `client`: our client virtual IP address; + /// `server`: server's logical name in the config; + /// `link`: the link name including the `[ ]`. #[clap(long)] print_config: Option, } @@ -332,7 +336,12 @@ async fn main() { &opts.config, &opts.log, |ics| { if let Some(arg) = &opts.print_config { for ic in &ics { - implement_print_config(arg, &|k| ic.inspect_key(k))?; + implement_print_config(arg, &|k| Some(match k { + "link" => &ic.link, + "server" => &ic.link.server, + "client" => &ic.link.client, + k => return ic.inspect_key(k), + }))?; } process::exit(0); } diff --git a/src/config.rs b/src/config.rs index fff0546..c20cfcd 100644 --- a/src/config.rs +++ b/src/config.rs @@ -142,6 +142,8 @@ impl<'i> Display for DisplayInspectable<'i> { } impl_inspectable_config_value!{ String as Display } +impl_inspectable_config_value!{ ServerName as Display } +impl_inspectable_config_value!{ ClientName as Display } impl_inspectable_config_value!{ u16 as Display } impl_inspectable_config_value!{ u32 as Display } impl_inspectable_config_value!{ hyper::Uri as Display }