mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 16:50:41 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fb57b421d | ||
|
|
72c1e6101f | ||
|
|
a67731052f | ||
|
|
e6089bfb46 | ||
|
|
aa2a341d15 | ||
|
|
9622bf4c1e | ||
|
|
d7e52a098b | ||
|
|
94ff1f1c02 | ||
|
|
aafc17e626 |
No files matched your search
Generated
+1
-1
@@ -2741,7 +2741,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uu-remote-linux"
|
name = "uu-remote-linux"
|
||||||
version = "0.2.4"
|
version = "0.2.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "uu-remote-linux"
|
name = "uu-remote-linux"
|
||||||
version = "0.2.4"
|
version = "0.2.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
default-run = "uuremote-server"
|
default-run = "uuremote-server"
|
||||||
authors = ["uu-remote-linux contributors"]
|
authors = ["uu-remote-linux contributors"]
|
||||||
|
|||||||
+8
-2
@@ -1,4 +1,4 @@
|
|||||||
# uu-remote-linux · Unofficial Linux host for NetEase UU Remote
|
# uu-remote-linux · Unofficial Linux host and viewer for NetEase UU Remote
|
||||||
|
|
||||||
[简体中文](README.md) | **English**
|
[简体中文](README.md) | **English**
|
||||||
|
|
||||||
@@ -7,13 +7,19 @@
|
|||||||
> NetEase UU Remote (网易 UU 远程) is a great remote-desktop tool, but there is no Linux version on its
|
> NetEase UU Remote (网易 UU 远程) is a great remote-desktop tool, but there is no Linux version on its
|
||||||
> official website. So, with the help of Claude and Codex, I wrote this open-source Linux host: install it,
|
> official website. So, with the help of Claude and Codex, I wrote this open-source Linux host: install it,
|
||||||
> and you can control your Linux machine from the official Mac / Windows / mobile UU Remote clients.
|
> and you can control your Linux machine from the official Mac / Windows / mobile UU Remote clients.
|
||||||
|
> It now also ships an **experimental Linux viewer**, `uuremote-viewer`, that controls official Windows / Mac hosts or this
|
||||||
|
> project's host from Linux (desktop, file transfer, terminal, port mapping, remote assistance; see
|
||||||
|
> [below](#experimental-native-viewer-uuremote-viewer)).
|
||||||
>
|
>
|
||||||
> This is a personal hobby project. **It is not affiliated with NetEase and is not an official client.**
|
> This is a personal hobby project. **It is not affiliated with NetEase and is not an official client.**
|
||||||
> If NetEase considers this project infringing or inappropriate, please DM me on X
|
> If NetEase considers this project infringing or inappropriate, please DM me on X
|
||||||
> **[@ai_fengshou](https://x.com/ai_fengshou)** and I will take it down right away.
|
> **[@ai_fengshou](https://x.com/ai_fengshou)** and I will take it down right away.
|
||||||
|
|
||||||
|
<p align="center"><img src="docs/images/viewer-window.png" width="720" alt="Linux viewer launcher: device list (device names redacted)"></p>
|
||||||
|
<p align="center"><sub>Linux viewer: device list (device names redacted)</sub></p>
|
||||||
|
|
||||||
<p align="center"><img src="docs/images/main-window.png" width="620" alt="Host main window: remote assistance and account"></p>
|
<p align="center"><img src="docs/images/main-window.png" width="620" alt="Host main window: remote assistance and account"></p>
|
||||||
<p align="center"><sub>The QR login window shown on first run (QR code blurred). The UI is in Chinese, like the official app.</sub></p>
|
<p align="center"><sub>Linux host main window: remote assistance and account (device ID, code and account redacted). The UI is in Chinese, like the official app.</sub></p>
|
||||||
|
|
||||||
<!-- Screenshot placeholder: the Linux desktop controlled from the official client. Take your own
|
<!-- Screenshot placeholder: the Linux desktop controlled from the official client. Take your own
|
||||||
screenshot, remove account/device details and NetEase logos, save it as docs/images/remote-desktop.png
|
screenshot, remove account/device details and NetEase logos, save it as docs/images/remote-desktop.png
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# uu-remote-linux · UU 远程 Linux 被控端(非官方)
|
# uu-remote-linux · UU 远程 Linux 被控端 + 控制端(非官方)
|
||||||
|
|
||||||
**简体中文** | [English](README.en.md)
|
**简体中文** | [English](README.en.md)
|
||||||
|
|
||||||
@@ -6,12 +6,17 @@
|
|||||||
>
|
>
|
||||||
> 网易 UU 远程非常好用,但官网一直没有 Linux 版本。于是我借助 Claude 和 Codex,写了这个开源的 Linux 被控端:
|
> 网易 UU 远程非常好用,但官网一直没有 Linux 版本。于是我借助 Claude 和 Codex,写了这个开源的 Linux 被控端:
|
||||||
> 装上之后,就能用官方的 Mac / Windows / 手机客户端远程控制你的 Linux 电脑。
|
> 装上之后,就能用官方的 Mac / Windows / 手机客户端远程控制你的 Linux 电脑。
|
||||||
|
> 现在还附带一个**实验性 Linux 控制端** `uuremote-viewer`:在 Linux 上用 UU 账号远控官方 Windows / Mac 被控端或本项目主机
|
||||||
|
> (桌面、文件传输、终端、端口映射、远程协助,详见[下文](#实验性原生控制端uuremote-viewer))。
|
||||||
>
|
>
|
||||||
> 这是个人兴趣项目,**与网易无关,也不是官方客户端**。如果网易认为本项目侵权或有不妥,
|
> 这是个人兴趣项目,**与网易无关,也不是官方客户端**。如果网易认为本项目侵权或有不妥,
|
||||||
> 请在推特私信我 **[@ai_fengshou](https://x.com/ai_fengshou)**,我会第一时间自行下架。
|
> 请在推特私信我 **[@ai_fengshou](https://x.com/ai_fengshou)**,我会第一时间自行下架。
|
||||||
|
|
||||||
|
<p align="center"><img src="docs/images/viewer-window.png" width="720" alt="Linux 控制端启动窗口:设备列表(设备名已打码)"></p>
|
||||||
|
<p align="center"><sub>Linux 控制端:设备列表(设备名已打码)</sub></p>
|
||||||
|
|
||||||
<p align="center"><img src="docs/images/main-window.png" width="620" alt="Linux 主机主窗口:远程协助与账号"></p>
|
<p align="center"><img src="docs/images/main-window.png" width="620" alt="Linux 主机主窗口:远程协助与账号"></p>
|
||||||
<p align="center"><sub>首次运行时弹出的扫码登录窗口(二维码已打码)</sub></p>
|
<p align="center"><sub>Linux 被控端主窗口:远程协助与账号(设备 ID、验证码和账号已打码)</sub></p>
|
||||||
|
|
||||||
<!-- 截图占位:在官方客户端里远控 Linux 桌面的效果图。请自行截图并去掉账号、设备名等信息后放到
|
<!-- 截图占位:在官方客户端里远控 Linux 桌面的效果图。请自行截图并去掉账号、设备名等信息后放到
|
||||||
docs/images/remote-desktop.png,再取消下面这行的注释。注意不要截入网易的图标和品牌素材。 -->
|
docs/images/remote-desktop.png,再取消下面这行的注释。注意不要截入网易的图标和品牌素材。 -->
|
||||||
|
|||||||
@@ -475,6 +475,8 @@ static void build_window(void) {
|
|||||||
static void *ui_main(void *arg) {
|
static void *ui_main(void *arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
int ok = gtk_init_check(NULL, NULL);
|
int ok = gtk_init_check(NULL, NULL);
|
||||||
|
// The CSS hard-codes a light palette; a dark system theme would turn unstyled text white on white (#43).
|
||||||
|
if (ok) g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
||||||
if (ok) build_window();
|
if (ok) build_window();
|
||||||
pthread_mutex_lock(&init_lock);
|
pthread_mutex_lock(&init_lock);
|
||||||
init_state = ok ? 1 : -1;
|
init_state = ok ? 1 : -1;
|
||||||
|
|||||||
@@ -474,6 +474,8 @@ static gboolean show_window(gpointer d) {
|
|||||||
static void *ui_thread(void *d) {
|
static void *ui_thread(void *d) {
|
||||||
(void)d;
|
(void)d;
|
||||||
if (!gtk_init_check(NULL, NULL)) { pthread_mutex_lock(&init_lock); init_state = -1; pthread_cond_signal(&init_cond); pthread_mutex_unlock(&init_lock); return NULL; }
|
if (!gtk_init_check(NULL, NULL)) { pthread_mutex_lock(&init_lock); init_state = -1; pthread_cond_signal(&init_cond); pthread_mutex_unlock(&init_lock); return NULL; }
|
||||||
|
// Light palette in CSS; keep a dark system theme from making unstyled text white on white (#43).
|
||||||
|
g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
||||||
show_window(NULL); gtk_main(); return NULL;
|
show_window(NULL); gtk_main(); return NULL;
|
||||||
}
|
}
|
||||||
/* Hidden windows retain their widgets so queued idle callbacks stay valid. */
|
/* Hidden windows retain their widgets so queued idle callbacks stay valid. */
|
||||||
|
|||||||
@@ -590,6 +590,8 @@ static gboolean on_delete(GtkWidget *w, GdkEvent *e, gpointer d) { (void)w; (voi
|
|||||||
static void *run(void *arg) {
|
static void *run(void *arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
int ok = gtk_init_check(NULL, NULL);
|
int ok = gtk_init_check(NULL, NULL);
|
||||||
|
// The CSS hard-codes a light palette; a dark system theme would turn unstyled text white on white (#43).
|
||||||
|
if (ok) g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
GtkCssProvider *css = gtk_css_provider_new();
|
GtkCssProvider *css = gtk_css_provider_new();
|
||||||
gtk_css_provider_load_from_data(css, CSS, -1, NULL);
|
gtk_css_provider_load_from_data(css, CSS, -1, NULL);
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 161 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 255 KiB |
@@ -0,0 +1,21 @@
|
|||||||
|
窗口颜色修复;控制端可接收官方 Mac 被控端的剪贴板。/ Window colors fixed; viewer receives the official Mac host's clipboard.
|
||||||
|
|
||||||
|
### 修复 / Fixed
|
||||||
|
- **深色系统主题下窗口文字看不见**(#43):协助窗口、控制端启动窗口和工具窗口使用固定浅色背景,但部分文字跟随系统深色主题变成了白色。
|
||||||
|
现在这些窗口固定使用浅色主题。已在虚拟机中设置深色偏好后截图确认。
|
||||||
|
GTK windows now stay on the light theme, so text is readable under dark system themes.
|
||||||
|
- **控制端 ↔ 官方 Mac 被控端剪贴板**:Mac 被控端以 `public.utf8-plain-text`(UTF-8)提供文本,而不是 Windows 的 `CF_UNICODETEXT`,
|
||||||
|
之前控制端不会请求,剪贴板始终不同步。现在两种格式都支持;主机端发给官方客户端的格式不变。
|
||||||
|
Mac → 控制端已实机验证;⚠️ 控制端 → Mac 尚未验证。
|
||||||
|
The viewer now handles the Mac host's UTF-8 text format (Mac → viewer verified live; viewer → Mac not yet verified).
|
||||||
|
|
||||||
|
### 已验证 / Verified with the official Mac host(FFmpeg 9.0.2)
|
||||||
|
- 画面 0 解码错误,键盘输入正确,文件上传/下载/列目录 sha256 一致。
|
||||||
|
|
||||||
|
### 已知问题 / Known issues
|
||||||
|
- 剪贴板只在控制端窗口获得焦点时同步;控制端 → 官方 Windows 被控端的剪贴板仍在排查。
|
||||||
|
|
||||||
|
### 下载 / Download
|
||||||
|
`uu-remote-linux-v0.2.5-x86_64-linux.tar.gz`:主机 `uuremote-server`(X11 版)与控制端 `uuremote-viewer`(x86_64,glibc ≥ 2.35;控制端需 SDL2、GTK3、ffmpeg),附带 `contrib/`。
|
||||||
|
|
||||||
|
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
控制端可打开官方 Mac 被控端的终端;输入问题诊断日志。/ Viewer terminal works with the official Mac host; input diagnostics.
|
||||||
|
|
||||||
|
### 控制端修复 / Viewer — fixed
|
||||||
|
- **连接官方 Mac 被控端的终端**:之前一连上就断开(「Terminal channel closed」)。Mac 被控端把终端的应答发在终端通道上,
|
||||||
|
控制端现在能识别。已实机验证:可打开终端并正常回显。Mac 被控端的端口映射也已实测可用。
|
||||||
|
Terminal sessions with the official Mac host now open (verified live); port mapping with it was verified too.
|
||||||
|
|
||||||
|
### 主机端诊断 / Host diagnostics(#46)
|
||||||
|
- 收到不认识的输入事件时记一条日志(只有动作名和字段名,**不含输入内容**),用于排查手机输入法打字无反应。
|
||||||
|
- 小键盘按键记录被控端当前的 NumLock 状态(只记开/关,不记按键),用于排查小键盘不出数字。
|
||||||
|
- Logs unsupported input actions (names only, never typed text) and the server's NumLock state for numpad keys.
|
||||||
|
|
||||||
|
### 其他 / Other
|
||||||
|
- README 标题与开头加入控制端介绍并放上截图(#44)。
|
||||||
|
|
||||||
|
### 下载 / Download
|
||||||
|
`uu-remote-linux-v0.2.6-x86_64-linux.tar.gz`:主机 `uuremote-server`(X11 版)与控制端 `uuremote-viewer`(x86_64,glibc ≥ 2.35;控制端需 SDL2、GTK3、ffmpeg),附带 `contrib/`。
|
||||||
|
|
||||||
|
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||||
+73
-12
@@ -5,11 +5,37 @@ use crate::protocol::{decode_wire,WireValue};
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
const UNICODE_TEXT:u64=13;
|
const UNICODE_TEXT:u64=13;
|
||||||
|
/// The official Mac host offers its pasteboard text as format id 0 named `public.utf8-plain-text` (observed live).
|
||||||
|
const MAC_TEXT:&str="public.utf8-plain-text";
|
||||||
|
#[derive(Clone,Copy,PartialEq,Eq,Debug)]
|
||||||
|
enum TextFormat {Windows,Mac}
|
||||||
|
impl TextFormat {
|
||||||
|
fn of(format:&[u8])->Option<Self>{
|
||||||
|
if number(format,1)==Ok(UNICODE_TEXT){return Some(Self::Windows)}
|
||||||
|
let named=|n|text_field(format,n).is_ok_and(|s|s==MAC_TEXT);
|
||||||
|
(named(2)||named(3)).then_some(Self::Mac)
|
||||||
|
}
|
||||||
|
fn id(self)->u64{match self{Self::Windows=>UNICODE_TEXT,Self::Mac=>0}}
|
||||||
|
fn name(self)->&'static str{match self{Self::Windows=>"CF_UNICODETEXT",Self::Mac=>MAC_TEXT}}
|
||||||
|
fn encode(self,text:&str)->Vec<u8>{match self{Self::Windows=>encode_windows(text),Self::Mac=>text.as_bytes().to_vec()}}
|
||||||
|
fn decode(self,data:&[u8])->Result<String,&'static str>{
|
||||||
|
match self{
|
||||||
|
Self::Windows=>decode_windows(data),
|
||||||
|
Self::Mac=>{
|
||||||
|
let data=data.strip_suffix(&[0]).unwrap_or(data);
|
||||||
|
if data.len()>MAX_TEXT{return Err("clipboard text exceeds limit");}
|
||||||
|
let text=std::str::from_utf8(data).map_err(|_|"invalid UTF-8 clipboard text")?;
|
||||||
|
if text.contains('\0'){return Err("embedded NUL in clipboard text");}
|
||||||
|
Ok(text.to_owned())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
const BLOCK_BYTES:usize=0x20000;
|
const BLOCK_BYTES:usize=0x20000;
|
||||||
const MAX_BYTES:usize=MAX_TEXT*2+2;
|
const MAX_BYTES:usize=MAX_TEXT*2+2;
|
||||||
pub struct ResultMessages {pub messages:Vec<(u32,Vec<u8>)>,pub text:Option<String>}
|
pub struct ResultMessages {pub messages:Vec<(u32,Vec<u8>)>,pub text:Option<String>}
|
||||||
impl Default for ResultMessages {fn default()->Self{Self{messages:Vec::new(),text:None}}}
|
impl Default for ResultMessages {fn default()->Self{Self{messages:Vec::new(),text:None}}}
|
||||||
struct Pending {key:String, count:Option<usize>, blocks:BTreeMap<usize,Vec<u8>>}
|
struct Pending {key:String, format:TextFormat, count:Option<usize>, blocks:BTreeMap<usize,Vec<u8>>}
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct State {local:Option<String>, pending:Option<Pending>}
|
pub struct State {local:Option<String>, pending:Option<Pending>}
|
||||||
pub fn format_ids(rpc:&[u8])->Vec<u64>{
|
pub fn format_ids(rpc:&[u8])->Vec<u64>{
|
||||||
@@ -62,12 +88,15 @@ fn decode_windows(data:&[u8])->Result<String,&'static str>{
|
|||||||
if text.len()>MAX_TEXT{return Err("clipboard text exceeds limit");}Ok(text)
|
if text.len()>MAX_TEXT{return Err("clipboard text exceeds limit");}Ok(text)
|
||||||
}
|
}
|
||||||
impl State{
|
impl State{
|
||||||
pub fn offer(&mut self,id:u64,text:String)->Result<Vec<u8>,&'static str>{
|
pub fn offer(&mut self,id:u64,text:String)->Result<Vec<u8>,&'static str>{self.offer_formats(id,text,&[TextFormat::Windows])}
|
||||||
|
/// Viewer offers: Windows hosts pick CF_UNICODETEXT, the official Mac host its UTF-8 type.
|
||||||
|
pub fn offer_any_host(&mut self,id:u64,text:String)->Result<Vec<u8>,&'static str>{self.offer_formats(id,text,&[TextFormat::Windows,TextFormat::Mac])}
|
||||||
|
fn offer_formats(&mut self,id:u64,text:String,formats:&[TextFormat])->Result<Vec<u8>,&'static str>{
|
||||||
if text.len()>MAX_TEXT{return Err("clipboard text exceeds limit");}
|
if text.len()>MAX_TEXT{return Err("clipboard text exceeds limit");}
|
||||||
if text.contains('\0')||encode_windows(&text).len()>MAX_BYTES{return Err("clipboard encoded text exceeds limit");}
|
if text.contains('\0')||encode_windows(&text).len()>MAX_BYTES{return Err("clipboard encoded text exceeds limit");}
|
||||||
self.local=Some(text);
|
self.local=Some(text);
|
||||||
let mut format=Vec::new();int(1,UNICODE_TEXT,&mut format);string(2,"CF_UNICODETEXT",&mut format);
|
let mut list=Vec::new();
|
||||||
let mut list=Vec::new();nested(1,&format,&mut list);
|
for kind in formats {let mut format=Vec::new();int(1,kind.id(),&mut format);string(2,kind.name(),&mut format);nested(1,&format,&mut list);}
|
||||||
Ok(request(id,1,&list))
|
Ok(request(id,1,&list))
|
||||||
}
|
}
|
||||||
pub fn request(&mut self,rpc:&[u8],next:&mut impl FnMut()->u64)->Result<ResultMessages,&'static str>{
|
pub fn request(&mut self,rpc:&[u8],next:&mut impl FnMut()->u64)->Result<ResultMessages,&'static str>{
|
||||||
@@ -78,22 +107,30 @@ impl State{
|
|||||||
if let Some(list)=bytes(clip,1)?{
|
if let Some(list)=bytes(clip,1)?{
|
||||||
out.messages.push((22,response(h,1,&[])));
|
out.messages.push((22,response(h,1,&[])));
|
||||||
let fields=decode_wire(list).map_err(|_|"invalid clipboard format list")?;
|
let fields=decode_wire(list).map_err(|_|"invalid clipboard format list")?;
|
||||||
let supports_text=fields.iter().filter(|f|f.number==1).any(|f|match f.value{WireValue::Bytes(format)=>number(format,1)==Ok(UNICODE_TEXT),_=>false});
|
let offered:Vec<TextFormat>=fields.iter().filter(|f|f.number==1).filter_map(|f|match f.value{WireValue::Bytes(format)=>TextFormat::of(format),_=>None}).collect();
|
||||||
|
let chosen=if offered.contains(&TextFormat::Windows){Some(TextFormat::Windows)}else{offered.first().copied()};
|
||||||
|
let supports_text=chosen.is_some();
|
||||||
self.pending=None;
|
self.pending=None;
|
||||||
if supports_text{
|
if !supports_text{
|
||||||
|
// Format ids/names only (never data), to learn non-Windows peers' text formats.
|
||||||
|
let formats:Vec<(u64,String)>=fields.iter().filter(|f|f.number==1).filter_map(|f|match f.value{WireValue::Bytes(format)=>Some(format),_=>None})
|
||||||
|
.take(8).map(|format|(number(format,1).unwrap_or(u64::MAX),decode_wire(format).ok().and_then(|x|x.into_iter().find_map(|y|match (y.number,y.value){(n,WireValue::Bytes(s)) if n!=1=>std::str::from_utf8(s).ok().map(|s|s.chars().take(48).collect()),_=>None})).unwrap_or_default())).collect();
|
||||||
|
log::info!("Clipboard offer without a supported text format: formats={formats:?}");
|
||||||
|
}
|
||||||
|
if let Some(format)=chosen{
|
||||||
let id=next();
|
let id=next();
|
||||||
let epoch=std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap_or_default().as_secs() as u32;
|
let epoch=std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap_or_default().as_secs() as u32;
|
||||||
let key=format!("{epoch:08x}-0000-4000-8000-{:012x}",id & 0xffffffffffff);
|
let key=format!("{epoch:08x}-0000-4000-8000-{:012x}",id & 0xffffffffffff);
|
||||||
let mut ask=Vec::new();int(1,UNICODE_TEXT,&mut ask);string(2,&key,&mut ask);string(3,"CF_UNICODETEXT",&mut ask);
|
let mut ask=Vec::new();int(1,format.id(),&mut ask);string(2,&key,&mut ask);string(3,format.name(),&mut ask);
|
||||||
self.pending=Some(Pending{key,count:None,blocks:BTreeMap::new()});
|
self.pending=Some(Pending{key,format,count:None,blocks:BTreeMap::new()});
|
||||||
out.messages.push((21,request(id,2,&ask)));
|
out.messages.push((21,request(id,2,&ask)));
|
||||||
}
|
}
|
||||||
}else if let Some(ask)=bytes(clip,2)?{
|
}else if let Some(ask)=bytes(clip,2)?{
|
||||||
let key=text_field(ask,2)?;
|
let key=text_field(ask,2)?;
|
||||||
if key.len()>256||key.is_empty(){return Err("invalid clipboard block key");}
|
if key.len()>256||key.is_empty(){return Err("invalid clipboard block key");}
|
||||||
let available=number(ask,1)?==UNICODE_TEXT&&self.local.is_some();
|
let format=if number(ask,1)?==UNICODE_TEXT{Some(TextFormat::Windows)}else if text_field(ask,3).is_ok_and(|s|s==MAC_TEXT){Some(TextFormat::Mac)}else{None};
|
||||||
let mut confirm=Vec::new();int(1,if available{1}else{2},&mut confirm);string(2,key,&mut confirm);
|
let data=format.zip(self.local.as_ref()).map(|(format,text)|format.encode(text));
|
||||||
let data=if available{Some(encode_windows(self.local.as_ref().unwrap()))}else{None};
|
let mut confirm=Vec::new();int(1,if data.is_some(){1}else{2},&mut confirm);string(2,key,&mut confirm);
|
||||||
if let Some(data)=&data{int(3,data.chunks(BLOCK_BYTES).len() as u64,&mut confirm);}
|
if let Some(data)=&data{int(3,data.chunks(BLOCK_BYTES).len() as u64,&mut confirm);}
|
||||||
out.messages.push((22,response(h,2,&confirm)));
|
out.messages.push((22,response(h,2,&confirm)));
|
||||||
if let Some(data)=data{
|
if let Some(data)=data{
|
||||||
@@ -144,13 +181,37 @@ impl State{
|
|||||||
else if (1..=count).all(|i|pending.blocks.contains_key(&i)){1}
|
else if (1..=count).all(|i|pending.blocks.contains_key(&i)){1}
|
||||||
else{return Ok(None);};
|
else{return Ok(None);};
|
||||||
let data:Vec<u8>=(first..first+count).flat_map(|i|pending.blocks[&i].iter().copied()).collect();
|
let data:Vec<u8>=(first..first+count).flat_map(|i|pending.blocks[&i].iter().copied()).collect();
|
||||||
self.pending=None;decode_windows(&data).map(Some)
|
let format=pending.format;self.pending=None;format.decode(&data).map(Some)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests{
|
mod tests{
|
||||||
use super::*;
|
use super::*;
|
||||||
|
#[test] fn mac_utf8_text_round_trips_both_directions(){
|
||||||
|
// Mac host offer: format list {1 id 0, 2 "public.utf8-plain-text"} (observed live).
|
||||||
|
let mut mac=Vec::new();int(1,0,&mut mac);string(2,MAC_TEXT,&mut mac);
|
||||||
|
let mut list=Vec::new();nested(1,&mac,&mut list);
|
||||||
|
let mut viewer=State::default();let mut id=200;let mut next=||{id+=1;id};
|
||||||
|
let asked=viewer.request(&request(7,1,&list),&mut next).unwrap();
|
||||||
|
assert_eq!(asked.messages.len(),2);
|
||||||
|
let ask_rpc=&asked.messages[1].1;let clip=bytes(ask_rpc,9).unwrap().unwrap();let ask=bytes(clip,2).unwrap().unwrap();
|
||||||
|
assert_eq!(number(ask,1),Ok(0));assert_eq!(text_field(ask,3),Ok(MAC_TEXT));
|
||||||
|
let key=text_field(ask,2).unwrap().to_owned();
|
||||||
|
let mut confirm=Vec::new();int(1,1,&mut confirm);string(2,&key,&mut confirm);int(3,1,&mut confirm);
|
||||||
|
assert_eq!(viewer.response(&response(header(ask_rpc).unwrap(),2,&confirm)).unwrap(),None);
|
||||||
|
let mut block=Vec::new();string(1,&key,&mut block);int(2,0,&mut block);nested(3,"中文 text\n".as_bytes(),&mut block);
|
||||||
|
assert_eq!(viewer.request(&request(8,3,&block),&mut next).unwrap().text.as_deref(),Some("中文 text\n"));
|
||||||
|
// Viewer offer lists both formats; a Mac-style ask gets UTF-8 bytes back.
|
||||||
|
let offer=viewer.offer_any_host(9,"hi".into()).unwrap();
|
||||||
|
assert_eq!(format_ids(&offer),vec![13,0]);
|
||||||
|
let mut ask=Vec::new();int(1,0,&mut ask);string(2,"k",&mut ask);string(3,MAC_TEXT,&mut ask);
|
||||||
|
let out=viewer.request(&request(10,2,&ask),&mut next).unwrap();
|
||||||
|
let data=bytes(bytes(bytes(&out.messages[1].1,9).unwrap().unwrap(),3).unwrap().unwrap(),3).unwrap().unwrap();
|
||||||
|
assert_eq!(data,b"hi");
|
||||||
|
// Host-side offers are unchanged: CF_UNICODETEXT only.
|
||||||
|
assert_eq!(format_ids(&State::default().offer(1,"hi".into()).unwrap()),vec![13]);
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn desktop_clipboard_negotiates_and_buffers_unicode_until_confirmation(){
|
fn desktop_clipboard_negotiates_and_buffers_unicode_until_confirmation(){
|
||||||
let text="UU-test-中文🙂\n".repeat(900);
|
let text="UU-test-中文🙂\n".repeat(900);
|
||||||
|
|||||||
@@ -248,6 +248,14 @@ impl InputInjector {
|
|||||||
if AUDIT.fetch_add(1,std::sync::atomic::Ordering::Relaxed) < 8 {
|
if AUDIT.fetch_add(1,std::sync::atomic::Ordering::Relaxed) < 8 {
|
||||||
log::info!("Desktop keyboard injection outcome: result={result}");
|
log::info!("Desktop keyboard injection outcome: result={result}");
|
||||||
}
|
}
|
||||||
|
// KP_0..KP_9 type digits only with NumLock on (#46); record the server's NumLock state, not the key.
|
||||||
|
static NUMPAD: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
|
||||||
|
if (0x60..=0x6f).contains(&key) && is_press && self.backend==crate::desktop_backend::DesktopBackend::X11
|
||||||
|
&& NUMPAD.fetch_add(1,std::sync::atomic::Ordering::Relaxed) < 4 {
|
||||||
|
let (mut x,mut y,mut mask)=(0,0,0u32);
|
||||||
|
let state=unsafe { x11_pointer_state(&mut x,&mut y,&mut mask) };
|
||||||
|
log::info!("Desktop numpad key: result={result} numlock={}", state==0 && mask & 0x10 != 0);
|
||||||
|
}
|
||||||
if result == 0 {
|
if result == 0 {
|
||||||
let mut held=self.held.lock().unwrap();
|
let mut held=self.held.lock().unwrap();
|
||||||
if is_press {held.keys.insert(symbol);} else {held.keys.remove(&symbol);}
|
if is_press {held.keys.insert(symbol);} else {held.keys.remove(&symbol);}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ impl SyncState {
|
|||||||
/// ignores the other form.
|
/// ignores the other form.
|
||||||
fn local(&mut self,value:String)->Result<Option<Vec<Vec<u8>>>,&'static str>{
|
fn local(&mut self,value:String)->Result<Option<Vec<Vec<u8>>>,&'static str>{
|
||||||
if self.last.as_ref()==Some(&value){return Ok(None)}
|
if self.last.as_ref()==Some(&value){return Ok(None)}
|
||||||
let id=self.next();let payload=self.rich.offer(id,value.clone())?;
|
let id=self.next();let payload=self.rich.offer_any_host(id,value.clone())?;
|
||||||
let rich=wire::envelope(self.next(),21,&payload);
|
let rich=wire::envelope(self.next(),21,&payload);
|
||||||
let text=wire::envelope(self.next(),21,&crate::clipboard_protocol::text_request(self.next(),&value));
|
let text=wire::envelope(self.next(),21,&crate::clipboard_protocol::text_request(self.next(),&value));
|
||||||
self.last=Some(value);Ok(Some(vec![rich,text]))
|
self.last=Some(value);Ok(Some(vec![rich,text]))
|
||||||
|
|||||||
+2
-1
@@ -195,7 +195,8 @@ impl Peer {
|
|||||||
if state.chroma.swap(chroma,Ordering::AcqRel)!=chroma {log::info!("Viewer capture sync: chroma={chroma}");}
|
if state.chroma.swap(chroma,Ordering::AcqRel)!=chroma {log::info!("Viewer capture sync: chroma={chroma}");}
|
||||||
}
|
}
|
||||||
let count=state.control_messages.fetch_add(1,Ordering::Relaxed);
|
let count=state.control_messages.fetch_add(1,Ordering::Relaxed);
|
||||||
if wire::echo_matches(&message.data,1) {state.clipboard_supported.store(wire::echo_clipboard_supported(&message.data),Ordering::Release);state.echo_received.store(true,Ordering::Release);}
|
if wire::echo_matches(&message.data,1) {let supported=wire::echo_clipboard_supported(&message.data);
|
||||||
|
if state.clipboard_supported.swap(supported,Ordering::AcqRel)!=supported || !state.echo_received.load(Ordering::Acquire) {log::info!("Viewer echo: clipboard_supported={supported}");}state.echo_received.store(true,Ordering::Release);}
|
||||||
if let Some(request)=wire::echo_request_seq(&message.data) {
|
if let Some(request)=wire::echo_request_seq(&message.data) {
|
||||||
if let Some(control)=control_for_echo.upgrade() {let _=control.send(&bytes::Bytes::from(wire::echo_response_with_clipboard(1_000_000+request,request,clipboard_enabled))).await;}
|
if let Some(control)=control_for_echo.upgrade() {let _=control.send(&bytes::Bytes::from(wire::echo_response_with_clipboard(1_000_000+request,request,clipboard_enabled))).await;}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ impl Window {
|
|||||||
use super::clipboard::ClipboardRequest;
|
use super::clipboard::ClipboardRequest;
|
||||||
match request {
|
match request {
|
||||||
ClipboardRequest::Read(reply)=>{
|
ClipboardRequest::Read(reply)=>{
|
||||||
|
if self.clipboard_dirty {log::debug!("Viewer clipboard read: focused={} has_text={}",self.focused,self.clipboard.has_clipboard_text());}
|
||||||
let result=if self.focused && std::mem::take(&mut self.clipboard_dirty) && self.clipboard.has_clipboard_text(){read_clipboard()}else{Ok(None)};
|
let result=if self.focused && std::mem::take(&mut self.clipboard_dirty) && self.clipboard.has_clipboard_text(){read_clipboard()}else{Ok(None)};
|
||||||
let _=reply.send(result);
|
let _=reply.send(result);
|
||||||
},
|
},
|
||||||
@@ -162,6 +163,8 @@ pub async fn run(session:&mut Session,window:&mut Window,decoder:&mut dyn super:
|
|||||||
|
|
||||||
#[cfg(test)] mod tests {
|
#[cfg(test)] mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
// macOS: SDL video must start on the main thread, which the test harness does not use; CI runs it on Linux.
|
||||||
|
#[cfg_attr(target_os="macos",ignore)]
|
||||||
#[tokio::test] async fn clipboard_requests_use_existing_window(){
|
#[tokio::test] async fn clipboard_requests_use_existing_window(){
|
||||||
if std::env::var_os("UU_VIEWER_CLIPBOARD_TEST_CHILD").is_none(){
|
if std::env::var_os("UU_VIEWER_CLIPBOARD_TEST_CHILD").is_none(){
|
||||||
let output=std::process::Command::new(std::env::current_exe().unwrap())
|
let output=std::process::Command::new(std::env::current_exe().unwrap())
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ impl Terminal {
|
|||||||
let worker=tokio::spawn(async move {
|
let worker=tokio::spawn(async move {
|
||||||
let mut decoder=Decoder::default();
|
let mut decoder=Decoder::default();
|
||||||
while let Some((channel,data))=rx.recv().await {
|
while let Some((channel,data))=rx.recv().await {
|
||||||
if channel==CONTROL {
|
// Terminal RPC answers (check_env) come on CONTROL or, from the official Mac host, on BINARY
|
||||||
|
// next to TERM frames (as this project's host does).
|
||||||
|
if channel==CONTROL || (channel==BINARY && !data.starts_with(b"TERM")) {
|
||||||
if let Some(r)=blob(&data,22) {if let (Some(h),Some(body))=(blob(r,1),blob(r,24)) {
|
if let Some(r)=blob(&data,22) {if let (Some(h),Some(body))=(blob(r,1),blob(r,24)) {
|
||||||
if let Some(t)=p.lock().unwrap().remove(&(24,uint(h,1))) {let _=t.send(Ok(body.to_vec()));}
|
if let Some(t)=p.lock().unwrap().remove(&(24,uint(h,1))) {let _=t.send(Ok(body.to_vec()));}
|
||||||
}}continue
|
}}continue
|
||||||
@@ -85,7 +87,12 @@ impl Terminal {
|
|||||||
// "not implemented", not "unavailable"; go on and let OPEN report availability.
|
// "not implemented", not "unavailable"; go on and let OPEN report availability.
|
||||||
match tokio::time::timeout(std::time::Duration::from_secs(3),self.request((24,id),CONTROL,wire::envelope(id,21,&r))).await{
|
match tokio::time::timeout(std::time::Duration::from_secs(3),self.request((24,id),CONTROL,wire::envelope(id,21,&r))).await{
|
||||||
Err(_)=>Ok(()),
|
Err(_)=>Ok(()),
|
||||||
Ok(b)=>{let b=b?;if uint(&b,1)!=0 {return Err("Terminal environment unavailable".into())}Ok(())}
|
Ok(b)=>{let b=b?;let code=uint(&b,1);
|
||||||
|
if code!=0 {
|
||||||
|
let message=blob(&b,2).map(|m|String::from_utf8_lossy(m).chars().take(80).collect::<String>()).unwrap_or_default();
|
||||||
|
log::info!("Terminal check_env: code={code} message={message:?}");
|
||||||
|
return Err("Terminal environment unavailable".into())
|
||||||
|
}Ok(())}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub async fn list_sessions(&self)->Result<Vec<Value>,String>{
|
pub async fn list_sessions(&self)->Result<Vec<Value>,String>{
|
||||||
|
|||||||
@@ -1071,6 +1071,16 @@ impl WebRtcSession {
|
|||||||
});}
|
});}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
Ok(crate::control_protocol::ControlMessage::Unsupported(v)) => {
|
||||||
|
// Action name and key names only, never values (an IME text event would carry typed text).
|
||||||
|
static UNSUPPORTED: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
|
||||||
|
if UNSUPPORTED.fetch_add(1, std::sync::atomic::Ordering::Relaxed) < 16 {
|
||||||
|
let action = v.get("action").and_then(serde_json::Value::as_str)
|
||||||
|
.filter(|a| a.len() <= 40 && a.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'_')).unwrap_or("?");
|
||||||
|
let keys: Vec<&str> = v.as_object().map(|o| o.keys().map(String::as_str).take(12).collect()).unwrap_or_default();
|
||||||
|
log::info!("Unsupported CONTROL input: action={action} keys={keys:?}");
|
||||||
|
}
|
||||||
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
} else if channel_name.contains("STREAMER") {
|
} else if channel_name.contains("STREAMER") {
|
||||||
|
|||||||
Reference in new issue
Block a user