Improve terminal input and client cleanup
ci / test (push) Has been cancelled
ci / remote-bench (push) Has been cancelled

This commit is contained in:
Codex
2026-06-11 14:32:55 -04:00
parent 14cdd5fd56
commit 2257aeca0b
3 changed files with 168 additions and 18 deletions
+40 -1
View File
@@ -18,6 +18,14 @@ fn free_udp_port() -> u16 {
}
fn write_server_config(dir: &tempfile::TempDir, port: u16) -> std::path::PathBuf {
write_server_config_with_timeout(dir, port, 30)
}
fn write_server_config_with_timeout(
dir: &tempfile::TempDir,
port: u16,
client_timeout_secs: u64,
) -> std::path::PathBuf {
let config_dir = dir.path().join(".config/dosh");
fs::create_dir_all(&config_dir).unwrap();
let config = config_dir.join("server.toml");
@@ -31,7 +39,7 @@ scrollback = 5000
auth_ttl_secs = 30
attach_ticket_ttl_secs = 3600
allow_attach_tickets = true
client_timeout_secs = 30
client_timeout_secs = {client_timeout_secs}
retransmit_window = 256
default_input_mode = "read-write"
prewarm_sessions = ["default"]
@@ -215,6 +223,37 @@ fn unknown_live_client_gets_reject() {
assert_eq!(reject.reason, "unknown client");
}
#[test]
fn disconnected_client_times_out_and_gets_reject() {
let dir = tempfile::tempdir().unwrap();
let port = free_udp_port();
let config = write_server_config_with_timeout(&dir, port, 1);
let mut server = start_server(&dir, &config);
let (socket, bootstrap, ok) = direct_attach(&config, port, "read-write");
thread::sleep(Duration::from_secs(6));
send_encrypted(
&socket,
port,
PacketKind::Ping,
ok.client_id,
2,
0,
&bootstrap.session_key,
b"",
);
let mut buf = [0u8; 65535];
let (n, _) = socket.recv_from(&mut buf).unwrap();
let packet = protocol::decode(&buf[..n]).unwrap();
let reject: AttachReject = protocol::from_body(&packet.body).unwrap();
let _ = server.kill();
let _ = server.wait();
assert_eq!(packet.header.kind, PacketKind::AttachReject);
assert_eq!(packet.header.conn_id, ok.client_id);
assert_eq!(reject.reason, "unknown client");
}
#[test]
fn local_attach_only_smoke() {
let dir = tempfile::tempdir().unwrap();