ALPHA: wire is a tool to deploy nixos systems wire.althaea.zone/
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

support ssh verbosity (#473)

authored by

marshmallow and committed by
GitHub
0b8b3d76 6017853f

+67 -32
+1
CHANGELOG.md
··· 10 10 ### Added 11 11 12 12 - "Encrypting with Sops" documentation example. 13 + - `--ssh-verbose` / `--sv` argument which increases verbosity of SSH commands. 13 14 14 15 ### Changed 15 16
+13 -1
crates/cli/src/cli.rs
··· 2 2 // Copyright 2024-2025 wire Contributors 3 3 4 4 use clap::builder::PossibleValue; 5 - use clap::{Args, Parser, Subcommand, ValueEnum}; 5 + use clap::{ArgAction, Args, Parser, Subcommand, ValueEnum}; 6 6 use clap::{ValueHint, crate_version}; 7 7 use clap_complete::CompletionCandidate; 8 8 use clap_complete::engine::ArgValueCompleter; ··· 213 213 /// Vulnerable to man-in-the-middle attacks, use with caution. 214 214 #[arg(long, default_value_t = false)] 215 215 pub ssh_accept_host: bool, 216 + 217 + /// Increase debug verbosity of SSH commands. 218 + #[arg(long, visible_alias = "sv", action = ArgAction::Count, default_value_t = 0, value_parser=less_than_3)] 219 + pub ssh_verbose: u8, 216 220 } 217 221 218 222 #[derive(Clone, Debug)] ··· 332 336 } 333 337 _ => wire_core::StrictHostKeyChecking::default(), 334 338 }, 339 + ssh_verbosity: match &self.command { 340 + Commands::Apply(args) => args.ssh_verbose.into(), 341 + _ => 0, 342 + }, 335 343 } 336 344 } 337 345 } ··· 379 387 380 388 completions 381 389 }) 390 + } 391 + 392 + fn less_than_3(s: &str) -> Result<u8, String> { 393 + number_range(s, 0, 3) 382 394 } 383 395 384 396 #[cfg(test)]
+47 -31
crates/core/src/commands/pty/output.rs
··· 221 221 status_sender: &watch::Sender<Status>, 222 222 began_tx: &mut Option<oneshot::Sender<()>>, 223 223 ) -> SearchFindings { 224 - let searched = aho_corasick 225 - .find_iter(haystack) 226 - .map(|x| x.pattern()) 227 - .collect::<Vec<_>>(); 224 + for haystack in haystack.split(|&b| b == b'\n') { 225 + if haystack.starts_with(b"debug") || haystack.starts_with(b"ssh") { 226 + tracing::log::log!( 227 + if haystack.starts_with(b"ssh") { 228 + tracing::log::Level::Error 229 + } else { 230 + tracing::log::Level::Debug 231 + }, 232 + "{}", 233 + String::from_utf8_lossy(haystack) 234 + ); 228 235 229 - let started = if searched.contains(&STARTED_PATTERN) { 230 - debug!("start needle was found, switching mode..."); 231 - if let Some(began_tx) = began_tx.take() { 232 - let _ = began_tx.send(()); 236 + continue; 233 237 } 234 - true 235 - } else { 236 - false 237 - }; 238 238 239 - let succeeded = if searched.contains(&SUCCEEDED_PATTERN) { 240 - debug!("succeed needle was found, marking child as succeeding."); 241 - status_sender.send_replace(Status::Done { success: true }); 242 - true 243 - } else { 244 - false 245 - }; 239 + let searched = aho_corasick 240 + .find_iter(haystack) 241 + .map(|x| x.pattern()) 242 + .collect::<Vec<_>>(); 246 243 247 - let failed = if searched.contains(&FAILED_PATTERN) { 248 - debug!("failed needle was found, elevated child did not succeed."); 249 - status_sender.send_replace(Status::Done { success: false }); 250 - true 251 - } else { 252 - false 253 - }; 244 + let started = if searched.contains(&STARTED_PATTERN) { 245 + debug!("start needle was found, switching mode..."); 246 + if let Some(began_tx) = began_tx.take() { 247 + let _ = began_tx.send(()); 248 + } 249 + true 250 + } else { 251 + false 252 + }; 253 + 254 + let succeeded = if searched.contains(&SUCCEEDED_PATTERN) { 255 + debug!("succeed needle was found, marking child as succeeding."); 256 + status_sender.send_replace(Status::Done { success: true }); 257 + true 258 + } else { 259 + false 260 + }; 261 + 262 + let failed = if searched.contains(&FAILED_PATTERN) { 263 + debug!("failed needle was found, elevated child did not succeed."); 264 + status_sender.send_replace(Status::Done { success: false }); 265 + true 266 + } else { 267 + false 268 + }; 254 269 255 - if succeeded || failed { 256 - return SearchFindings::Terminate; 257 - } 270 + if succeeded || failed { 271 + return SearchFindings::Terminate; 272 + } 258 273 259 - if started { 260 - return SearchFindings::Started; 274 + if started { 275 + return SearchFindings::Started; 276 + } 261 277 } 262 278 263 279 SearchFindings::None
+4
crates/core/src/hive/node.rs
··· 94 94 vector.push("-o".to_string()); 95 95 vector.extend(options.into_iter().intersperse("-o".to_string())); 96 96 97 + if modifiers.ssh_verbosity > 0 { 98 + vector.push(format!("-{}", "v".repeat(modifiers.ssh_verbosity))); 99 + } 100 + 97 101 Ok(vector) 98 102 } 99 103
+2
crates/core/src/lib.rs
··· 44 44 pub show_trace: bool, 45 45 pub non_interactive: bool, 46 46 pub ssh_accept_host: StrictHostKeyChecking, 47 + pub ssh_verbosity: usize, 47 48 } 48 49 49 50 impl Default for SubCommandModifiers { ··· 52 53 show_trace: false, 53 54 non_interactive: !std::io::stdin().is_terminal(), 54 55 ssh_accept_host: StrictHostKeyChecking::default(), 56 + ssh_verbosity: 0, 55 57 } 56 58 } 57 59 }