Fix stale client rejection and terminal cursor mode
ci / test (push) Has been cancelled
ci / remote-bench (push) Has been cancelled

This commit is contained in:
Codex
2026-06-11 14:14:15 -04:00
parent 8ffbb07bfa
commit 14cdd5fd56
3 changed files with 80 additions and 6 deletions
+24 -3
View File
@@ -9,8 +9,8 @@ use dosh::auth::{
use dosh::config::{expand_tilde, load_client_config, load_server_config};
use dosh::crypto;
use dosh::protocol::{
self, AttachOk, BootstrapAttachRequest, CLIENT_TO_SERVER, Frame, Input, PacketKind, Resize,
ResumeRequest, SERVER_TO_CLIENT, TicketAttachBody, TicketAttachEnvelope,
self, AttachOk, AttachReject, BootstrapAttachRequest, CLIENT_TO_SERVER, Frame, Input,
PacketKind, Resize, ResumeRequest, SERVER_TO_CLIENT, TicketAttachBody, TicketAttachEnvelope,
TicketAttachOkEnvelope,
};
use serde::{Deserialize, Serialize};
@@ -633,6 +633,10 @@ async fn run_terminal(
}
}
PacketKind::Pong => {}
PacketKind::AttachReject => {
let reject: AttachReject = protocol::from_body(&packet.body)?;
return Err(anyhow!("server rejected session: {}", reject.reason));
}
_ => {}
}
}
@@ -773,7 +777,7 @@ impl RawMode {
fn enter() -> Result<Self> {
enable_raw_mode()?;
let mut stdout = std::io::stdout();
stdout.write_all(TERMINAL_CLEANUP)?;
stdout.write_all(TERMINAL_OPEN)?;
stdout.flush()?;
Ok(Self)
}
@@ -788,6 +792,23 @@ impl Drop for RawMode {
}
}
const TERMINAL_OPEN: &[u8] = concat!(
"\x1b[?1l",
"\x1b[0m",
"\x1b[?25h",
"\x1b[?1003l",
"\x1b[?1002l",
"\x1b[?1001l",
"\x1b[?1000l",
"\x1b[?1015l",
"\x1b[?1006l",
"\x1b[?1005l",
"\x1b[?2004l",
"\x1b[?1049l",
"\x1b[?1h"
)
.as_bytes();
const TERMINAL_CLEANUP: &[u8] = concat!(
"\x1b[?1l",
"\x1b[0m",