From 10048060354abf6cfeff8feeb7e73c50c1386cf5 Mon Sep 17 00:00:00 2001 From: cnetst <34930270+cnetst@users.noreply.github.com> Date: Sat, 7 Nov 2026 11:21:56 +0800 Subject: [PATCH] Resolve the iOS default upload directory alias (#198) Co-authored-by: Codex --- README.en.md | 2 +- README.md | 2 +- src/file_trans.rs | 64 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/README.en.md b/README.en.md index 87ba190..d54d6f8 100644 --- a/README.en.md +++ b/README.en.md @@ -80,7 +80,7 @@ Protocol strings and messages that come from the UU servers are shown as the ser | Viewer annotation | Strokes drawn with 「批注」 (annotate) in the viewer's watch mode appear on the Linux screen and stream back to the viewer (X11, needs a compositing manager; the overlay lets clicks through); cleared when annotation is turned off or the viewer disconnects. Verified with the Mac viewer 4.42.0; mobile viewers untested | | Quality / frame rate / resolution | Auto, Original 20M, Ultra 8M, HD 2M, custom; 30/60/90/144 fps; on X11 a resolution choice changes the desktop resolution itself like the official Windows host (xrandr, adding the mode when missing; restored for "original" or on disconnect), `UU_DESKTOP_RESIZE=0` scales in the encoder instead; Wayland scales in the encoder | | Sound | System audio captured from PulseAudio / PipeWire and sent as Opus | -| File transfer | Upload, download (including folders), create folder, rename, delete | +| File transfer | Upload, download (including folders), create folder, rename, delete; iOS quick uploads use the default receive directory (the current user’s home) | | Terminal | The official "Terminal" tool, PTY sessions, multiple sessions, rename | | Lock state and auto unlock | Lock state is reported to the viewer; with "auto unlock" enabled in the client, the password is verified with PAM and the session is unlocked | | Lock after remote session | Stored on the host, so it still applies after reconnecting | diff --git a/README.md b/README.md index d951681..c07d8ca 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ UU_LANG=en uuremote-server | 观看模式批注 | 控制端观看模式下开启「批注」后画的笔迹显示在 Linux 屏幕上,并随画面传回控制端(X11,需要合成器;覆盖层不拦截鼠标);关闭批注或断开连接时清除。已用 Mac 控制端 4.42.0 实测,手机控制端未测 | | 画质 / 帧率 / 分辨率 | 自动、原画 20M、超清 8M、高清 2M、自定义;30/60/90/144 帧;X11 下切换分辨率会像官方 Windows 被控端一样真正修改桌面分辨率(xrandr,缺少该模式时自动添加;选「原始」或断开后恢复),`UU_DESKTOP_RESIZE=0` 改为仅由编码器缩放;Wayland 仍由编码器缩放 | | 声音 | 采集系统声音(PulseAudio / PipeWire),Opus 编码传到控制端 | -| 文件传输 | 上传、下载(含文件夹)、新建文件夹、重命名、删除 | +| 文件传输 | 上传、下载(含文件夹)、新建文件夹、重命名、删除;iOS 直接上传使用默认接收目录(当前用户的主目录) | | 终端 | 官方「终端」工具,PTY 会话,支持多会话和重命名 | | 锁屏与自动解锁 | 向控制端上报锁屏状态;开启「自动解锁被控端」后,通过 PAM 校验密码并解锁当前会话 | | 远程结束后自动锁屏 | 设置保存在本机,重连后依然生效 | diff --git a/src/file_trans.rs b/src/file_trans.rs index c759a87..7f1b242 100644 --- a/src/file_trans.rs +++ b/src/file_trans.rs @@ -147,6 +147,10 @@ fn io_error(e: &std::io::Error) -> u64 { /// anything else is rooted at "/". pub fn normalize(path: &str) -> PathBuf { let p = path.replace('\\', "/"); + // Official Mac 4.46.0 UURemoteServer (x86_64, 0x10019f8a5–0x10019f9f7) + // resolves :/Default to its receive directory. iOS quick upload sends this alias; + // our receive directory is HOME, also reported in SystemMetrics/RemoteDownloadPath. + if p.trim_end_matches('/') == ":/Default" { return home(); } // The host registers as a PC, so the viewer builds drive paths ("C:/x", or ":/" when it // knows no drive letter). Linux has a single root: any drive prefix maps to "/". let p = match p.split_once(':') { @@ -455,7 +459,10 @@ impl FileSession { /// Upload to this host. receive_request{1 id,2 path,3 files,4 strategy,5 folder_name,6 list_data,7 task_unique_id} fn receive_request(&self, rid: u64, f: &[WireField]) { let id = TaskId::parse(f); - let target = normalize(&get_text(f, 2)); + let raw_target = get_text(f, 2); + let target = normalize(&raw_target); + log::info!("File transfer upload destination: default={} exists={}", + raw_target.replace('\\', "/").trim_end_matches('/') == ":/Default", target.is_dir()); let folder = get_text(f, 5); let strategy = get_uint(f, 4); let files = parse_files(get_all(f, 3), get_bytes(f, 6)); @@ -715,6 +722,61 @@ mod tests { assert_eq!(parse_files(vec![], Some(&gz.finish().unwrap())), files); } #[test] + fn ios_default_path_resolves_to_the_advertised_receive_directory() { + for path in [":/Default", ":\\Default", ":/Default/"] { + assert_eq!(normalize(path), home()); + assert!(!is_this_pc(path)); + } + assert_eq!(normalize("/Default"), PathBuf::from("/Default")); + assert_eq!(normalize("C:/Default"), PathBuf::from("/Default")); + assert_eq!(normalize(":/Default-other"), PathBuf::from("/Default-other")); + } + #[test] + fn ios_quick_upload_checks_conflicts_writes_and_completes_in_default_directory() { + let name = format!(".uu-ios-test-{}-{}", std::process::id(), + std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos()); + let dir = home().join(&name); + std::fs::create_dir(&dir).unwrap(); + struct Cleanup(PathBuf); + impl Drop for Cleanup { fn drop(&mut self) { let _ = std::fs::remove_dir_all(&self.0); } } + let _cleanup = Cleanup(dir.clone()); + let rel = format!("{name}/x.bin"); + std::fs::write(dir.join("x.bin"), b"old").unwrap(); + let (tx, mut rx) = mpsc::unbounded_channel(); + let s = FileSession::new(tx, Arc::new(AtomicU64::new(1))); + let call = |case: u32, body: Enc| { + let rpc = Enc::default().msg(1, Enc::default().uint(1, 17)).msg(8, Enc::default().msg(case, body)); + assert!(s.handle(&decode_wire(&crate::initialization::envelope(1, 1, 21, &rpc.0)).unwrap())); + }; + let response = |m: Vec, case: u32| { + let outer = decode_wire(&m).unwrap(); + let rpc = decode_wire(get_bytes(&outer, 22).unwrap()).unwrap(); + assert_eq!(get_uint(&decode_wire(get_bytes(&rpc, 1).unwrap()).unwrap(), 1), 17); + let ftp = decode_wire(get_bytes(&rpc, 4).unwrap()).unwrap(); + get_bytes(&ftp, case).unwrap().to_vec() + }; + call(11, Enc::default().text(1, ":/Default").text(2, &rel)); + let exist = response(rx.try_recv().unwrap(), 8); + let exist = decode_wire(&exist).unwrap(); + assert_eq!(get_text(&exist, 1), ":/Default"); + assert_eq!(get_uint(&decode_wire(get_bytes(&exist, 2).unwrap()).unwrap(), 2), 1); + let id = TaskId { task: 991, index: 1 }; + let info = FileInfo { rel_path: rel, size: 6, modified: 0 }; + call(1, Enc::default().msg(1, id.enc()).text(2, ":/Default").bytes(6, &list_data(&[info]))); + let received = response(rx.try_recv().unwrap(), 1); + assert_eq!(get_uint(&decode_wire(&received).unwrap(), 3), FT_SUCCEEDED); + call(3, Enc::default().msg(1, id.enc()).uint(3, 6)); + let confirmed = response(rx.try_recv().unwrap(), 3); + assert_eq!(get_uint(&decode_wire(&confirmed).unwrap(), 3), FT_SUCCEEDED); + call(4, Enc::default().msg(1, id.enc()).bytes(3, b"abcdef")); + let block = response(rx.try_recv().unwrap(), 4); + assert_eq!(get_uint(&decode_wire(&block).unwrap(), 3), FT_SUCCEEDED); + call(9, Enc::default().msg(1, id.enc()).uint(2, FT_SUCCEEDED)); + let done = response(rx.try_recv().unwrap(), 6); + assert_eq!(get_uint(&decode_wire(&done).unwrap(), 2), FT_SUCCEEDED); + assert_eq!(std::fs::read(dir.join("x.bin")).unwrap(), b"abcdef"); + } + #[test] fn upload_writes_blocks_and_confirms() { let dir = std::env::temp_dir().join(format!("uu-up-{}", std::process::id())); std::fs::create_dir_all(&dir).unwrap();