Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e69be4fdf0 | ||
|
|
fdbd58b628 |
Generated
+1
-1
@@ -436,7 +436,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dosh"
|
name = "dosh"
|
||||||
version = "1.0.0-rc33"
|
version = "1.0.0-rc35"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64",
|
"base64",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dosh"
|
name = "dosh"
|
||||||
version = "1.0.0-rc33"
|
version = "1.0.0-rc35"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
|
|||||||
@@ -85,12 +85,13 @@ dosh trace --client-log /tmp/dosh-client.log HOST
|
|||||||
Summarize collected traces with:
|
Summarize collected traces with:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
dosh trace report --client-log /tmp/dosh-client.log
|
dosh trace report HOST --client-log /tmp/dosh-client.log
|
||||||
```
|
```
|
||||||
|
|
||||||
Set `DOSH_TRACE=/tmp/dosh-server.log` on `dosh-server` for matching server
|
When `HOST` is given, Dosh fetches `/tmp/dosh-server.log` over SSH before
|
||||||
events. Trace byte prefixes are enabled for `dosh trace`, so use it only for
|
building the report. Set `DOSH_TRACE=/tmp/dosh-server.log` on `dosh-server` for
|
||||||
short reproductions.
|
matching server events. Trace byte prefixes are enabled for `dosh trace`, so use
|
||||||
|
it only for short reproductions.
|
||||||
|
|
||||||
## VS Code
|
## VS Code
|
||||||
|
|
||||||
|
|||||||
+228
-36
@@ -71,7 +71,7 @@ const MAX_PENDING_USER_INPUT_BYTES: usize = 1024 * 1024;
|
|||||||
const STARTUP_INPUT_HOLD: Duration = Duration::from_millis(750);
|
const STARTUP_INPUT_HOLD: Duration = Duration::from_millis(750);
|
||||||
const POST_SUBMIT_ALL_INPUT_HOLD: Duration = Duration::from_millis(120);
|
const POST_SUBMIT_ALL_INPUT_HOLD: Duration = Duration::from_millis(120);
|
||||||
const STALE_TERMINAL_INPUT_AFTER: Duration = Duration::from_secs(2);
|
const STALE_TERMINAL_INPUT_AFTER: Duration = Duration::from_secs(2);
|
||||||
const POST_RECONNECT_STALE_INPUT_GRACE: Duration = Duration::from_secs(2);
|
const POST_RECONNECT_STALE_INPUT_GRACE: Duration = Duration::from_secs(5);
|
||||||
const FOCUS_REPAINT_COOLDOWN: Duration = Duration::from_secs(1);
|
const FOCUS_REPAINT_COOLDOWN: Duration = Duration::from_secs(1);
|
||||||
const ALT_SCREEN_IDLE_REPAINT_AFTER: Duration = Duration::from_secs(15);
|
const ALT_SCREEN_IDLE_REPAINT_AFTER: Duration = Duration::from_secs(15);
|
||||||
const LOCAL_SLEEP_REPAINT_AFTER: Duration = Duration::from_secs(5);
|
const LOCAL_SLEEP_REPAINT_AFTER: Duration = Duration::from_secs(5);
|
||||||
@@ -792,8 +792,9 @@ struct TraceOptions {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
struct TraceReportOptions {
|
struct TraceReportOptions {
|
||||||
|
host: Option<String>,
|
||||||
client_log: Option<PathBuf>,
|
client_log: Option<PathBuf>,
|
||||||
server_log: Option<PathBuf>,
|
server_log: Option<String>,
|
||||||
tail: usize,
|
tail: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -888,15 +889,16 @@ fn parse_trace_options(command: &[String]) -> Result<TraceOptions> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn parse_trace_report_options(command: &[String]) -> Result<TraceReportOptions> {
|
fn parse_trace_report_options(command: &[String]) -> Result<TraceReportOptions> {
|
||||||
|
let mut host: Option<String> = None;
|
||||||
let mut client_log: Option<PathBuf> = None;
|
let mut client_log: Option<PathBuf> = None;
|
||||||
let mut server_log: Option<PathBuf> = Some(PathBuf::from("/tmp/dosh-server.log"));
|
let mut server_log: Option<String> = Some("/tmp/dosh-server.log".to_string());
|
||||||
let mut tail = 20usize;
|
let mut tail = 20usize;
|
||||||
let mut index = 0usize;
|
let mut index = 0usize;
|
||||||
while index < command.len() {
|
while index < command.len() {
|
||||||
match command[index].as_str() {
|
match command[index].as_str() {
|
||||||
"--client-log" => {
|
"--client-log" => {
|
||||||
let path = command.get(index + 1).ok_or_else(|| {
|
let path = command.get(index + 1).ok_or_else(|| {
|
||||||
anyhow!("usage: dosh trace report [--client-log PATH] [--server-log PATH|none] [--tail N]")
|
anyhow!("usage: dosh trace report [HOST] [--client-log PATH] [--server-log PATH|none] [--tail N]")
|
||||||
})?;
|
})?;
|
||||||
client_log = Some(expand_tilde(path));
|
client_log = Some(expand_tilde(path));
|
||||||
index += 2;
|
index += 2;
|
||||||
@@ -911,7 +913,7 @@ fn parse_trace_report_options(command: &[String]) -> Result<TraceReportOptions>
|
|||||||
}
|
}
|
||||||
"--server-log" => {
|
"--server-log" => {
|
||||||
let path = command.get(index + 1).ok_or_else(|| {
|
let path = command.get(index + 1).ok_or_else(|| {
|
||||||
anyhow!("usage: dosh trace report [--client-log PATH] [--server-log PATH|none] [--tail N]")
|
anyhow!("usage: dosh trace report [HOST] [--client-log PATH] [--server-log PATH|none] [--tail N]")
|
||||||
})?;
|
})?;
|
||||||
server_log = parse_optional_trace_path(path);
|
server_log = parse_optional_trace_path(path);
|
||||||
index += 2;
|
index += 2;
|
||||||
@@ -929,7 +931,7 @@ fn parse_trace_report_options(command: &[String]) -> Result<TraceReportOptions>
|
|||||||
}
|
}
|
||||||
"--tail" => {
|
"--tail" => {
|
||||||
let value = command.get(index + 1).ok_or_else(|| {
|
let value = command.get(index + 1).ok_or_else(|| {
|
||||||
anyhow!("usage: dosh trace report [--client-log PATH] [--server-log PATH|none] [--tail N]")
|
anyhow!("usage: dosh trace report [HOST] [--client-log PATH] [--server-log PATH|none] [--tail N]")
|
||||||
})?;
|
})?;
|
||||||
tail = parse_trace_tail(value)?;
|
tail = parse_trace_tail(value)?;
|
||||||
index += 2;
|
index += 2;
|
||||||
@@ -941,25 +943,35 @@ fn parse_trace_report_options(command: &[String]) -> Result<TraceReportOptions>
|
|||||||
tail = parse_trace_tail(value)?;
|
tail = parse_trace_tail(value)?;
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
value => {
|
value if value.starts_with('-') => {
|
||||||
return Err(anyhow!(
|
return Err(anyhow!(
|
||||||
"usage: dosh trace report [--client-log PATH] [--server-log PATH|none] [--tail N] (unknown option {value})"
|
"usage: dosh trace report [HOST] [--client-log PATH] [--server-log PATH|none] [--tail N] (unknown option {value})"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
value => {
|
||||||
|
if host.is_some() {
|
||||||
|
return Err(anyhow!(
|
||||||
|
"usage: dosh trace report [host] [--client-log PATH] [--server-log PATH|none] [--tail N]"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
host = Some(value.to_string());
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(TraceReportOptions {
|
Ok(TraceReportOptions {
|
||||||
|
host,
|
||||||
client_log,
|
client_log,
|
||||||
server_log,
|
server_log,
|
||||||
tail,
|
tail,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_optional_trace_path(value: &str) -> Option<PathBuf> {
|
fn parse_optional_trace_path(value: &str) -> Option<String> {
|
||||||
if matches!(value, "" | "none" | "off" | "0") {
|
if matches!(value, "" | "none" | "off" | "0") {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(expand_tilde(value))
|
Some(value.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1006,7 +1018,8 @@ fn sanitize_trace_name(value: &str) -> String {
|
|||||||
|
|
||||||
fn run_trace_command(args: &Args) -> Result<()> {
|
fn run_trace_command(args: &Args) -> Result<()> {
|
||||||
if args.command.first().is_some_and(|value| value == "report") {
|
if args.command.first().is_some_and(|value| value == "report") {
|
||||||
return run_trace_report_command(&args.command[1..]);
|
let config = load_client_config(None).unwrap_or_default();
|
||||||
|
return run_trace_report_command(&config, args, &args.command[1..]);
|
||||||
}
|
}
|
||||||
let options = parse_trace_options(&args.command)?;
|
let options = parse_trace_options(&args.command)?;
|
||||||
if let Some(parent) = options.client_log.parent() {
|
if let Some(parent) = options.client_log.parent() {
|
||||||
@@ -1042,7 +1055,11 @@ fn run_trace_command(args: &Args) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_trace_report_command(command: &[String]) -> Result<()> {
|
fn run_trace_report_command(
|
||||||
|
config: &dosh::config::ClientConfig,
|
||||||
|
args: &Args,
|
||||||
|
command: &[String],
|
||||||
|
) -> Result<()> {
|
||||||
let options = parse_trace_report_options(command)?;
|
let options = parse_trace_report_options(command)?;
|
||||||
let client_log = match options.client_log {
|
let client_log = match options.client_log {
|
||||||
Some(path) => Some(path),
|
Some(path) => Some(path),
|
||||||
@@ -1061,6 +1078,20 @@ fn run_trace_report_command(command: &[String]) -> Result<()> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if let Some(path) = options.server_log {
|
if let Some(path) = options.server_log {
|
||||||
|
let server_log = if let Some(host) = options.host.as_deref() {
|
||||||
|
match fetch_trace_server_log(config, args, host, &path) {
|
||||||
|
Ok(path) => Some(path),
|
||||||
|
Err(err) => {
|
||||||
|
println!("[warn] server log {host}:{path}: {err:#}");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Some(expand_tilde(&path))
|
||||||
|
};
|
||||||
|
let Some(path) = server_log else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
match summarize_trace_file(&path, options.tail) {
|
match summarize_trace_file(&path, options.tail) {
|
||||||
Ok(report) => print_trace_report("server", &report),
|
Ok(report) => print_trace_report("server", &report),
|
||||||
Err(err)
|
Err(err)
|
||||||
@@ -1076,6 +1107,66 @@ fn run_trace_report_command(command: &[String]) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fetch_trace_server_log(
|
||||||
|
config: &dosh::config::ClientConfig,
|
||||||
|
args: &Args,
|
||||||
|
requested: &str,
|
||||||
|
remote_log: &str,
|
||||||
|
) -> Result<PathBuf> {
|
||||||
|
let hosts = load_hosts_config(None).unwrap_or_default();
|
||||||
|
let host_config = hosts.hosts.get(requested).cloned().unwrap_or_default();
|
||||||
|
let server = status_ssh_target(requested, &host_config);
|
||||||
|
let ssh_port = args.ssh_port.or(host_config.ssh_port).or(config.ssh_port);
|
||||||
|
if is_local_status_target(&server) {
|
||||||
|
return Ok(expand_tilde(remote_log));
|
||||||
|
}
|
||||||
|
let local_path = fetched_trace_server_log_path(requested);
|
||||||
|
if let Some(parent) = local_path.parent() {
|
||||||
|
fs::create_dir_all(parent)
|
||||||
|
.with_context(|| format!("create trace log directory {}", parent.to_string_lossy()))?;
|
||||||
|
}
|
||||||
|
let mut command = Command::new("ssh");
|
||||||
|
if let Some(ssh_port) = ssh_port {
|
||||||
|
command.arg("-p").arg(ssh_port.to_string());
|
||||||
|
}
|
||||||
|
command.arg("-T");
|
||||||
|
if let Some(key) = args.ssh_key.as_deref() {
|
||||||
|
command.arg("-i").arg(key);
|
||||||
|
}
|
||||||
|
if let Some(known_hosts) = args.ssh_known_hosts.as_deref() {
|
||||||
|
command
|
||||||
|
.arg("-o")
|
||||||
|
.arg(format!("UserKnownHostsFile={}", known_hosts.display()));
|
||||||
|
}
|
||||||
|
let script = format!("test -r {0} && cat {0}", shell_word(remote_log));
|
||||||
|
let output = command
|
||||||
|
.arg(&server)
|
||||||
|
.arg(format!("sh -c {}", shell_word(&script)))
|
||||||
|
.output()
|
||||||
|
.with_context(|| format!("fetch server trace log from {server}"))?;
|
||||||
|
anyhow::ensure!(
|
||||||
|
output.status.success(),
|
||||||
|
"{}",
|
||||||
|
String::from_utf8_lossy(&output.stderr)
|
||||||
|
);
|
||||||
|
fs::write(&local_path, &output.stdout)
|
||||||
|
.with_context(|| format!("write fetched server trace {}", local_path.display()))?;
|
||||||
|
Ok(local_path)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fetched_trace_server_log_path(host: &str) -> PathBuf {
|
||||||
|
let now = SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.map(|duration| duration.as_secs())
|
||||||
|
.unwrap_or(0);
|
||||||
|
trace_cache_dir().join(format!(
|
||||||
|
"server-{}-{}-{}.log",
|
||||||
|
sanitize_trace_name(host),
|
||||||
|
now,
|
||||||
|
std::process::id()
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
fn trace_cache_dir() -> PathBuf {
|
fn trace_cache_dir() -> PathBuf {
|
||||||
dirs::cache_dir()
|
dirs::cache_dir()
|
||||||
.unwrap_or_else(|| expand_tilde("~/.cache"))
|
.unwrap_or_else(|| expand_tilde("~/.cache"))
|
||||||
@@ -5575,8 +5666,62 @@ async fn run_terminal(
|
|||||||
dosh::trace::event("client.escape", &[]);
|
dosh::trace::event("client.escape", &[]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
let input_status_tick_gap = last_status_tick_at.elapsed();
|
||||||
|
let mut refreshed_before_input = false;
|
||||||
|
if should_reconnect_before_input_for_local_sleep(
|
||||||
|
forward_only,
|
||||||
|
input_status_tick_gap,
|
||||||
|
) {
|
||||||
|
dosh::trace::event(
|
||||||
|
"client.local_sleep_input_reconnect_start",
|
||||||
|
&[(
|
||||||
|
"tick_gap_ms",
|
||||||
|
input_status_tick_gap.as_millis().to_string(),
|
||||||
|
)],
|
||||||
|
);
|
||||||
|
last_status_tick_at = Instant::now();
|
||||||
|
arm_stale_terminal_input_suppression(
|
||||||
|
&mut stale_terminal_input_suppress_until,
|
||||||
|
);
|
||||||
|
if let Some(frame) = reconnect(
|
||||||
|
&socket,
|
||||||
|
&mut cred,
|
||||||
|
&mut send_seq,
|
||||||
|
last_size,
|
||||||
|
&mut frame_buffer,
|
||||||
|
&mut predictor,
|
||||||
|
)
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
dosh::trace::event(
|
||||||
|
"client.local_sleep_input_reconnect_ok",
|
||||||
|
&[
|
||||||
|
("output_seq", frame.output_seq.to_string()),
|
||||||
|
("bytes", frame.bytes.len().to_string()),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
refresh_live_addr(&mut addr, &cred)?;
|
||||||
|
render_frame(&frame)?;
|
||||||
|
predictor.observe_output(&frame.bytes);
|
||||||
|
last_terminal_frame_at = Instant::now();
|
||||||
|
last_packet_at = Instant::now();
|
||||||
|
last_focus_repaint_at = Instant::now();
|
||||||
|
refreshed_before_input = true;
|
||||||
|
flush_pending_user_input(
|
||||||
|
&socket,
|
||||||
|
addr,
|
||||||
|
&cred,
|
||||||
|
&mut send_seq,
|
||||||
|
&mut predictor,
|
||||||
|
&mut pending_user_input,
|
||||||
|
&mut pending_user_input_bytes,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
let saw_focus_in = input_contains_focus_in(&bytes);
|
let saw_focus_in = input_contains_focus_in(&bytes);
|
||||||
if !forward_only
|
if !forward_only
|
||||||
|
&& !refreshed_before_input
|
||||||
&& saw_focus_in
|
&& saw_focus_in
|
||||||
&& last_focus_repaint_at.elapsed() >= FOCUS_REPAINT_COOLDOWN
|
&& last_focus_repaint_at.elapsed() >= FOCUS_REPAINT_COOLDOWN
|
||||||
{
|
{
|
||||||
@@ -6996,6 +7141,13 @@ fn should_strip_stale_terminal_reports(
|
|||||||
|| suppress_until.is_some_and(|deadline| Instant::now() < deadline)
|
|| suppress_until.is_some_and(|deadline| Instant::now() < deadline)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn should_reconnect_before_input_for_local_sleep(
|
||||||
|
forward_only: bool,
|
||||||
|
status_tick_gap: Duration,
|
||||||
|
) -> bool {
|
||||||
|
!forward_only && status_tick_gap >= LOCAL_SLEEP_REPAINT_AFTER
|
||||||
|
}
|
||||||
|
|
||||||
fn should_strip_unowned_terminal_reports(alternate_screen: bool, mouse_tracking: bool) -> bool {
|
fn should_strip_unowned_terminal_reports(alternate_screen: bool, mouse_tracking: bool) -> bool {
|
||||||
!alternate_screen && !mouse_tracking
|
!alternate_screen && !mouse_tracking
|
||||||
}
|
}
|
||||||
@@ -7053,6 +7205,13 @@ fn should_repaint_idle_terminal(
|
|||||||
|
|
||||||
fn arm_stale_terminal_input_suppression(suppress_until: &mut Option<Instant>) {
|
fn arm_stale_terminal_input_suppression(suppress_until: &mut Option<Instant>) {
|
||||||
*suppress_until = Some(Instant::now() + POST_RECONNECT_STALE_INPUT_GRACE);
|
*suppress_until = Some(Instant::now() + POST_RECONNECT_STALE_INPUT_GRACE);
|
||||||
|
dosh::trace::event(
|
||||||
|
"client.stale_terminal_quarantine_arm",
|
||||||
|
&[(
|
||||||
|
"grace_ms",
|
||||||
|
POST_RECONNECT_STALE_INPUT_GRACE.as_millis().to_string(),
|
||||||
|
)],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn flush_pending_user_input(
|
async fn flush_pending_user_input(
|
||||||
@@ -8992,24 +9151,25 @@ mod tests {
|
|||||||
use super::{
|
use super::{
|
||||||
ALT_SCREEN_IDLE_REPAINT_AFTER, CachedCredential, DisconnectStatus, DynamicForward,
|
ALT_SCREEN_IDLE_REPAINT_AFTER, CachedCredential, DisconnectStatus, DynamicForward,
|
||||||
FRAME_GAP_RESYNC_AFTER_MS, FrameBuffer, LOCAL_SLEEP_REPAINT_AFTER, LocalForward,
|
FRAME_GAP_RESYNC_AFTER_MS, FrameBuffer, LOCAL_SLEEP_REPAINT_AFTER, LocalForward,
|
||||||
MAX_PENDING_USER_INPUT_BYTES, NativeIdentityContext, POST_SUBMIT_ALL_INPUT_HOLD,
|
MAX_PENDING_USER_INPUT_BYTES, NativeIdentityContext, POST_RECONNECT_STALE_INPUT_GRACE,
|
||||||
PendingStreamOpen, PredictMode, Predictor, RESTART_STATUS_SCRIPT, RemoteForward,
|
POST_SUBMIT_ALL_INPUT_HOLD, PendingStreamOpen, PredictMode, Predictor,
|
||||||
STARTUP_INPUT_HOLD, SshConfig, SshPathTokenContext, StartupGateMode, StatusAction,
|
RESTART_STATUS_SCRIPT, RemoteForward, STARTUP_INPUT_HOLD, SshConfig, SshPathTokenContext,
|
||||||
UpdateOptions, UpdateRole, auth_allows, cache_key, cache_server_prefix,
|
StartupGateMode, StatusAction, UpdateOptions, UpdateRole, auth_allows, cache_key,
|
||||||
cleanup_stream_state, clear_cached_credentials, ensure_tui_safe_status_overlay,
|
cache_server_prefix, cleanup_stream_state, clear_cached_credentials,
|
||||||
expand_ssh_path_tokens, input_contains_focus_in, input_matches_escape,
|
ensure_tui_safe_status_overlay, expand_ssh_path_tokens, input_contains_focus_in,
|
||||||
is_local_status_target, is_resume_response_for_client, latest_release_download_url,
|
input_matches_escape, is_local_status_target, is_resume_response_for_client,
|
||||||
load_first_native_identity_with_prompt, native_proxy_udp_warning, parse_dynamic_forward,
|
latest_release_download_url, load_first_native_identity_with_prompt,
|
||||||
parse_escape_key, parse_local_forward, parse_remote_forward, parse_ssh_config,
|
native_proxy_udp_warning, parse_dynamic_forward, parse_escape_key, parse_local_forward,
|
||||||
parse_trace_line, parse_trace_options, parse_trace_report_options, parse_trace_summary,
|
parse_remote_forward, parse_ssh_config, parse_trace_line, parse_trace_options,
|
||||||
parse_update_options, post_submit_hold_duration, queue_pending_user_input,
|
parse_trace_report_options, parse_trace_summary, parse_update_options,
|
||||||
queue_stale_pending_user_input, raw_contains_host_table, recv_response_until,
|
post_submit_hold_duration, queue_pending_user_input, queue_stale_pending_user_input,
|
||||||
refresh_live_addr, release_tag_download_url, release_tag_from_effective_url,
|
raw_contains_host_table, recv_response_until, refresh_live_addr, release_tag_download_url,
|
||||||
release_version_from_tag, render_status_clear, render_status_overlay, requested_env,
|
release_tag_from_effective_url, release_version_from_tag, render_status_clear,
|
||||||
resolved_startup_command, retire_stream_state, retransmit_stream_opens,
|
render_status_overlay, requested_env, resolved_startup_command, retire_stream_state,
|
||||||
rewrite_forward_command, sanitize_trace_name, selected_predict_mode, selected_udp_host,
|
retransmit_stream_opens, rewrite_forward_command, sanitize_trace_name,
|
||||||
server_version_mismatch, should_flush_terminal_input_after_contact,
|
selected_predict_mode, selected_udp_host, server_version_mismatch,
|
||||||
should_hold_during_startup_gate, should_hold_post_submit_input,
|
should_flush_terminal_input_after_contact, should_hold_during_startup_gate,
|
||||||
|
should_hold_post_submit_input, should_reconnect_before_input_for_local_sleep,
|
||||||
should_repaint_idle_terminal, should_strip_unowned_terminal_reports,
|
should_repaint_idle_terminal, should_strip_unowned_terminal_reports,
|
||||||
split_after_command_submit, split_trace_tokens, ssh_command_target, ssh_config_uses_proxy,
|
split_after_command_submit, split_trace_tokens, ssh_command_target, ssh_config_uses_proxy,
|
||||||
ssh_destination_host, ssh_username, ssh_with_user, startup_command, status_ssh_target,
|
ssh_destination_host, ssh_username, ssh_with_user, startup_command, status_ssh_target,
|
||||||
@@ -10324,27 +10484,30 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn trace_report_options_parse_defaults_and_overrides() {
|
fn trace_report_options_parse_defaults_and_overrides() {
|
||||||
let parsed = parse_trace_report_options(&[]).unwrap();
|
let parsed = parse_trace_report_options(&[]).unwrap();
|
||||||
|
assert_eq!(parsed.host, None);
|
||||||
assert_eq!(parsed.client_log, None);
|
assert_eq!(parsed.client_log, None);
|
||||||
assert_eq!(
|
assert_eq!(parsed.server_log, Some("/tmp/dosh-server.log".to_string()));
|
||||||
parsed.server_log,
|
|
||||||
Some(std::path::PathBuf::from("/tmp/dosh-server.log"))
|
|
||||||
);
|
|
||||||
assert_eq!(parsed.tail, 20);
|
assert_eq!(parsed.tail, 20);
|
||||||
|
|
||||||
let parsed = parse_trace_report_options(&[
|
let parsed = parse_trace_report_options(&[
|
||||||
|
"palav".to_string(),
|
||||||
"--client-log=/tmp/client.log".to_string(),
|
"--client-log=/tmp/client.log".to_string(),
|
||||||
"--server-log".to_string(),
|
"--server-log".to_string(),
|
||||||
"none".to_string(),
|
"/tmp/server.log".to_string(),
|
||||||
"--tail".to_string(),
|
"--tail".to_string(),
|
||||||
"3".to_string(),
|
"3".to_string(),
|
||||||
])
|
])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
assert_eq!(parsed.host.as_deref(), Some("palav"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parsed.client_log,
|
parsed.client_log,
|
||||||
Some(std::path::PathBuf::from("/tmp/client.log"))
|
Some(std::path::PathBuf::from("/tmp/client.log"))
|
||||||
);
|
);
|
||||||
assert_eq!(parsed.server_log, None);
|
assert_eq!(parsed.server_log.as_deref(), Some("/tmp/server.log"));
|
||||||
assert_eq!(parsed.tail, 3);
|
assert_eq!(parsed.tail, 3);
|
||||||
|
|
||||||
|
let parsed = parse_trace_report_options(&["--server-log=none".to_string()]).unwrap();
|
||||||
|
assert_eq!(parsed.server_log, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -11040,6 +11203,35 @@ mod tests {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn local_sleep_gap_reconnects_before_forwarding_input() {
|
||||||
|
assert!(should_reconnect_before_input_for_local_sleep(
|
||||||
|
false,
|
||||||
|
LOCAL_SLEEP_REPAINT_AFTER
|
||||||
|
));
|
||||||
|
assert!(should_reconnect_before_input_for_local_sleep(
|
||||||
|
false,
|
||||||
|
LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(10)
|
||||||
|
));
|
||||||
|
assert!(!should_reconnect_before_input_for_local_sleep(
|
||||||
|
false,
|
||||||
|
LOCAL_SLEEP_REPAINT_AFTER - Duration::from_millis(1)
|
||||||
|
));
|
||||||
|
assert!(!should_reconnect_before_input_for_local_sleep(
|
||||||
|
true,
|
||||||
|
LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(10)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reconnect_mouse_quarantine_is_long_enough_for_sleep_wake_noise() {
|
||||||
|
assert!(POST_RECONNECT_STALE_INPUT_GRACE >= LOCAL_SLEEP_REPAINT_AFTER);
|
||||||
|
assert_eq!(
|
||||||
|
strip_stale_mouse_reports(b"35;152;1M\x1b[A35;149;1M"),
|
||||||
|
b"\x1b[A"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn non_mouse_escape_input_survives_stale_filter() {
|
fn non_mouse_escape_input_survives_stale_filter() {
|
||||||
assert_eq!(strip_stale_mouse_reports(b"\x1b[A"), b"\x1b[A");
|
assert_eq!(strip_stale_mouse_reports(b"\x1b[A"), b"\x1b[A");
|
||||||
|
|||||||
Reference in New Issue
Block a user