UDP 47824 做发现,TCP 47823 做命令。帧 = 一行 UTF-8 JSON,以 \n 结尾,单帧上限 64MB
(文件用 base64 内联,接收端默认限制 32MB 明文)。
手机向每个网卡的广播地址(含 255.255.255.255)发:
{"app":"LANCMD","v":1,"type":"discover"}接收端单播回:
{"app":"LANCMD","v":1,"type":"agent","name":"DESKTOP-8K2",
"host":"DESKTOP-8K2","port":47823,"os":"Windows","ver":"1.5.1",
"id":"9f3c1a7b2e","auto_accept":true,
"ips":["192.168.1.5","192.168.137.1","10.8.0.2"],
"lan_ips":["192.168.1.5","192.168.137.1"],
"hotspot_ips":["192.168.137.1"]}id 是本机派生标识(主机名+架构+CPU 数),用于多机区分;不含任何凭据。
网卡字段说明:
| 字段 | 含义 |
|---|---|
ips |
本机全部 IPv4(含 VPN 网卡),诊断用 |
lan_ips |
排除 VPN 后的局域网地址,手机优先从这里挑 |
hotspot_ips |
识别为 Windows 移动热点的网卡地址(通常是 192.168.137.1) |
电脑可能同时有 Wi-Fi、热点、VPN 多块网卡。手机收到应答后按以下顺序选地址: 与当前手机网络同网段 → 与应答源地址相同 → 列表第一个。 选错的表现是「发现了却连不上」,所以这一步不能省。
| 场景 | 手机侧 | 电脑侧 |
|---|---|---|
| 手机开 VPN | 每个物理 Network 单独 bindSocket 后广播,绕开 tun 路由;跳过 TRANSPORT_VPN 网络 |
— |
| 电脑开热点 | 探测帧额外单播发往默认网关(热点场景网关即电脑);连「无互联网 Wi-Fi」时首次即连网关,超时 2.5s | 热点网卡名(Wi-Fi Direct、本地连接*、Mobile Hotspot)不判为 VPN,正常上报 |
| 电脑开热点 + 防火墙 | — | 必须放行 47823/47824。--fix-firewall 或 Start.exe 一键处理(自动提权) |
| 电脑开 VPN | — | lan_ips 排除 tap/tun/wireguard 等网卡,避免手机连到不可达地址 |
识别规则:网卡名含 tap/tun/vpn/ppp/wireguard/utun/ipsec/zerotier/tailscale/clash → 判为 VPN 排除;
含 wi-fi direct / 本地连接* / mobile hotspot → 判为热点保留。
VMware / VirtualBox / Hyper-V 网卡不排除,它们有时确实能到局域网。
没有应答就换手动 IP,协议一致。
{"id":1,"cmd":"hello","v":1,"client":"LanCmd 手机","client_id":"and-<uuid>","token":""}client_id首次由手机生成并存本地,之后不变。- 当前接收端不校验 token 来限制连接;
token为空或不符时仍完成握手,并返回已有或新建的配对 token。 auto_accept在发现应答中固定为true。--auto-accept/--no-auto-accept是被忽略的兼容参数,没有确认窗口或approval_timeout。
成功:
{"id":1,"ok":true,"paired":true,"token":"<32 hex>",
"agent":"DESKTOP-8K2","agent_id":"9f3c1a7b2e","fresh":true}agent_id是电脑的稳定标识(主机名+架构+CPU 数派生)。手机重连时用它核对 “还是不是同一台电脑”,即使 IP 变了也能认回来。fresh表示是否新建配对记录:首次配对为true,已有配对记录为false。它不是授权凭据。
| 场景 | 行为 |
|---|---|
| 手机断 Wi-Fi / 杀进程 | TCP 连接由 RST 或 keepalive 超时(30s 空闲探测、10s×3 次)判定失效 |
| 手机重连 | 发送 hello,返回 paired=true、fresh=false(已有记录) |
| 电脑端进程重启 | paired.json 持久化,返回已有配对记录;手机重新握手 |
| 电脑端 IP 变化 | 手机每 3 次失败重新 UDP 广播,按 agent_id 认回同一台机器 |
| 手机侧网络恢复 | ConnectivityManager 回调立即触发重连,不等退避计时 |
| 心跳 | 手机每 20s ping,连续 3 次超时(10s)主动断开并重连;其他请求在途时暂停心跳失败判定 |
电脑端不设 TCP 连接空闲超时;单次断线只结束该连接线程, 监听循环与发现应答继续提供服务(看护线程会在循环意外退出时退避重启)。
之后每条请求都要先握手;未握手的请求返回 未授权,请先握手(ecode 401)。
配对记录存 paired.json,手机存 SharedPreferences;当前 token 不构成访问控制。
请求:{"id":<int>,"cmd":"<name>", ...参数}
响应:{"id":<int>,"ok":true, ...结果} 或 {"id":<int>,"ok":false,"error":"...","ecode":<int>}
id 由客户端递增,用于并发匹配;服务端原样回填。
| cmd | 参数 | 成功返回 |
|---|---|---|
info |
— | name host user os arch python agent cpus cwd uptime_s drives[] lan_ips[] hotspot_ips[] interfaces[] firewall_ok admin |
exec |
shell(cmd/powershell/sh) line cwd? timeout? |
code out err ms |
ls |
path |
path parent items[{name,dir,size,mtime}] |
get |
path max? |
name path size sha256 data(base64),仅限 ≤32MB |
put |
path data(base64) overwrite? |
path size,仅限 ≤32MB |
upload |
见下节 | 分块上传(大文件) |
download |
见下节 | 分块下载(大文件) |
rm |
path |
removed |
mkdir |
path |
path |
rename |
path to |
from to |
screenshot |
sid |
1.5.0 起等同 screen,要求屏幕会话,返回 JPEG |
lock |
— | locked |
power |
action(shutdown/restart/logoff/sleep) |
action |
clip |
action(get/set) text? |
text |
ps |
filter? |
items[{name,pid,mem,mem_bytes,session}] total self_pid |
kill |
pid force? |
pid killed out |
ping |
— | ts(ms) |
agent |
action(status/stop) |
name ver uptime_s clients / stopping |
info 里 firewall_ok 用于让手机判断「连不上是不是防火墙拦的」,
interfaces[].vpn/hotspot 供排查网卡选择问题。
错误码:1 一般错误,2 超过文件上限,3 传输会话不存在/过期,
4 分块序号错乱,5 数据超过声明大小,6 大小不匹配,7 sha256 校验失败,
8 拒绝结束受保护进程,9 结束进程失败,401 未握手,403 共享会话不存在、已停止或作用域/身份不符。
1.6.1 起,ps 返回额外的 admin 布尔值,表示接收端进程当前的 Windows 管理员状态。旧版本缺少此字段时客户端显示未知权限。此字段只查询状态,不触发提权;管理员启动需要在电脑 Start.exe 中操作并经 UAC 允许,现有普通权限进程不会自行升级权限。
Windows capabilities.features 新增 audio、local_input。
audio:action=get返回volume(0–100 整数)、muted(布尔)。action=set至少提供一个volume/muted,修改后返回实际设备状态;两个字段独立,不自动取消静音。没有默认音频设备时返回错误。local_input:需要当前连接拥有的input会话sid。action=status/pause/release;1.7.2 起仅支持手动解除(不限时长),seconds可省略或为整数 0;非零时长返回错误,不启动暂停。1.7.0/1.7.1 的 1–30 秒模式不再支持。返回paused、remaining(手动解除时为 null)。不可替换正在使用的暂停会话,不按总时长自动恢复。其他连接无法解除该会话。status与普通会话 keepalive 更新活跃时间;暂停期间超过 12 秒没有会话活动即恢复。Android 每 3 秒查询状态,退出共享关闭会话立即恢复。- 本机解除:物理键盘同时按 A R T E X + Ctrl + Delete,或 Ctrl+Alt+Del。1.7.1 起不创建本机暂停提示窗口,状态与解除方法显示在安卓端。仅抑制键鼠事件,不能覆盖安全桌面或独立触屏原始输入,不修改硬件驱动。远程输入通过专用标记保留,远程合成的解除组合不会触发物理解除。
input.keys新增 WindowsOEM_1/OEM_PLUS/OEM_COMMA/OEM_MINUS/OEM_PERIOD/OEM_2/OEM_3/OEM_4/OEM_5/OEM_6/OEM_7标点虚拟键,遵循电脑当前键盘布局。仍只发送完整的按下/释放组合,最多 5 键,不提供跨请求的持续按住状态。
单帧上限 64MB、base64 后膨胀 4/3,所以大于几十 MB 的文件不能塞进一帧。 大文件走三阶段会话,块大小由接收端下发(默认 512KB):
{"id":10,"cmd":"upload","action":"begin","path":"C:\Users\me\a.zip","size":104857600}
{"id":10,"ok":true,"sid":"9a07b24dd8a3c281","chunk":524288,"path":"C:\Users\me\a.zip"}{"id":11,"cmd":"upload","action":"chunk","sid":"9a07...","seq":0,"data":"<base64>"}
{"id":11,"ok":true,"received":524288,"total":104857600}{"id":12,"cmd":"upload","action":"end","sid":"9a07...","sha256":"<可选>"}
{"id":12,"ok":true,"path":"C:\Users\me\a.zip","size":104857600,"sha256":"..."}seq必须从 0 连续递增,错序直接报错(防止丢块悄悄写坏文件)- 数据先写
目标.<sid>.lancmd-part,end时大小与可选 sha256 校验通过后提交。overwrite默认true;设为false时,提交会原子拒绝已存在的目标,即使目标是在上传期间新建的。 - 1.5.1 起严格拒绝非法 base64 和超过声明总大小的分块,拒绝时不推进块序号或写入数据。提交失败会清理传输会话与临时文件。小文件
put的overwrite=false同样使用独占创建。 {"action":"abort"}或连接断开时删除临时文件,不留半截- 默认上限
max_upload_bytes= 4GB
{"id":20,"cmd":"download","action":"begin","path":"C:\big.iso"}
{"id":20,"ok":true,"sid":"...","name":"big.iso","size":104857600,"chunk":524288}
{"id":21,"cmd":"download","action":"chunk","sid":"...","offset":0,"len":524288}
{"id":21,"ok":true,"offset":0,"data":"<base64>","eof":false,"size":104857600}
{"id":22,"cmd":"download","action":"end","sid":"..."}按 offset 随机读,客户端逐块推进;eof=true 表示已到文件尾。
会话挂在 TCP 连接上,连接断开即释放文件句柄。
- 每个连接独立的
uploads/downloads表,互不串扰 transfer_idle_sec(默认 600s)无进展的会话会被回收,避免手机中途消失占着临时文件- 手机侧协程取消时会先发
abort再断开,电脑端立即清理
{"id":7,"cmd":"exec","shell":"cmd","line":"ipconfig /all"}
{"id":7,"ok":true,"code":0,"out":"Windows IP 配置\r\n...","err":"","ms":42}exec在 Windows 下用cmd /c "chcp 65001>nul & <line>"(或 powershell 前置[Console]::OutputEncoding=[Text.Encoding]::UTF8)统一成 UTF-8,再按 utf-8 → gbk → mbcs 多级解码兜底;CREATE_NO_WINDOW防止闪黑框。screen/screenshot使用 GDI 捕获全部显示器,camera使用 Media Foundation;WIC 编码 JPEG,不依赖 Pillow,最大单帧 4MB。- 每个 TCP 连接一个线程,长连接保持,不设连接空闲超时。
exec_timeout=0表示接收端不限制命令时长,客户端仍可通过timeout指定单次执行时限。 - 监听套接字启用 TCP keepalive(idle 30s / interval 10s / count 3), 半开连接约 60s 内被内核判定失效,不会长期占用。
- 端口被上一次实例占用时持续重试(最长 30 次、退避 0.2~2s),不直接退出。
- 单实例保护:
agent.pid+ 存活检测;--stop读取 pid 终止。 ps在 Windows 用tasklist /fo csv /nh解析,内存列12,345 K转换为mem_bytes供排序;self_pid回传接收端自身 PID,客户端据此禁止“一键结束自己”。kill拒绝pid 0/1与接收端自身;失败时把taskkill原始报错回传(而不是只给退出码)。- 看护线程:TCP 监听与 UDP 应答各由一个 Supervisor 托管,循环异常退出后按 2s→30s 退避自动重启,保证接收端长期在线。
SIGTERM/SIGINT/SIGBREAK/SIGHUP均触发优雅退出并清理 pid 文件。
所有命令先完成 hello。屏幕、摄像头和键盘使用独立作用域的会话 ID;当前接收端创建会话时不要求本机确认。
| cmd | 参数 | 成功返回 |
|---|---|---|
capabilities |
— | version features[] session_seconds |
storage |
— | home drives[{path,total,free,used,percent}] |
session |
action:"begin" scope:"screen"/"camera"/"input" |
sid scope expires_in:null |
session |
action:"keepalive" sid |
active:true |
session |
action:"end" sid |
stopped:true,重复调用也成功 |
screen |
sid |
format:"jpeg" data(base64) |
camera |
sid action:"list" |
devices[{id,name}] |
camera |
sid device:0..31 action:"frame" |
format:"jpeg" data(base64) |
input |
sid keys:["CTRL","V"] 或 sid text:"你好" |
sent:true |
pointer |
sid action x y button? delta? |
sent:true(Windows 1.6.0 起) |
message |
title? text |
sent:true(桌面消息已排入显示) |
- 会话绑定当前 TCP 连接、客户端 ID 和作用域,重连必须重新创建。
expires_in和capabilities.session_seconds均为null,没有总时长或空闲时限。 - 手机页面进入后台时发送
end;连接关闭时接收端释放该连接的所有会话。接收端没有本机会话窗口;本机可停止整个接收服务。 - 手机通过原连接释放会话,不将旧会话 ID 发到自动重连后的新电脑连接。键盘页每 8 秒保活;屏幕约 800ms、摄像头约 1200ms 请求一帧(还需加上采集耗时)。这是 JPEG 预览,没有录音与视频编码。
- 按键与文字二选一;组合键最多 5 个不同按键,文字最多 1000 字。只控制当前用户桌面的前台应用;无法控制 UAC 安全桌面或权限更高的应用。
- 消息 1–2000 字、标题最多 60 字;后端最多同时显示 3 个消息框,不设每连接发送间隔。
- 手机
hello.client统一为「LanCmd 手机」,不再发送制造商或机型;client_id保持不变用于配对记录和会话身份。 screenshot与screen均要求有效的屏幕会话 ID。旧手机的其他命令仍兼容;工作台页面需要 Windows 1.5.0 或更新版本及完整辅助程序。
capabilities.features 新增 pointer。鼠标命令使用 input 作用域会话,不能复用屏幕会话;与按键共享同一连接。action 可为 move、click、double_click、down、up、scroll,button 为 left(默认)、right 或 middle;滚动的 delta 为 -10 到 10 的非零整数,每步 120 个 Windows 滚轮单位。
x、y 是完整虚拟桌面 JPEG 的归一化坐标,必须是 0 到 1 的有限数值。Windows 使用绝对虚拟桌面坐标,因此兼容截图缩放及位于主显示器左侧、上方的屏幕。Android 按 FIT_CENTER 实际画面映射,黑边不产生点击;拖动离开图像时将结束位置限制在图像边缘。
{"id":21,"cmd":"pointer","sid":"input-session-id","action":"click","x":0.5,"y":0.5,"button":"left"}停止输入会话、关闭连接或发送输入失败时,接收端释放该会话持有的鼠标按键。另一个会话不能移动或释放正在拖动的鼠标。up 可重复调用;停止和旋转页面也会结束当前手势。
Android 工作台建立画面、键鼠和终端三条专属连接,各自重新握手,绑定原目标。exec 不占用键鼠或画面连接。停止等待终端结果不等于撤销已经执行的电脑命令;命令仍受客户端指定的执行超时约束。页面不自动开始共享,离开或切换电脑后需要重新开始。
Windows capabilities.features 新增 devices。完成握手后使用:
{"id":1,"cmd":"devices","action":"list"}
{"id":2,"cmd":"devices","action":"policy","scope":"storage","mode":"blocked"}
{"id":3,"cmd":"devices","action":"policy","scope":"storage","mode":"read_only"}
{"id":4,"cmd":"devices","action":"policy","scope":"portable","mode":"blocked"}
{"id":5,"cmd":"devices","action":"policy","scope":"storage","mode":"allow"}
{"id":6,"cmd":"devices","action":"eject","device_id":"列表返回的完整 PnP ID"}list(默认动作)返回 admin、devices 及 policies。设备字段:id/name/kind/size/paths/protected/ejectable;kind 为 storage 或 portable,size 为字节,paths 为挂载路径数组。仅列出 USB 存储和 USB 便携设备。系统磁盘可显示但禁止弹出。
policies.storage / policies.portable 含 mode、managed、conflict;mode 为注册表配置的 allow/read_only/blocked,不代表当前驱动已生效。managed 表示存在 LanCmd 恢复记录;conflict 表示本机策略被其他程序改动。policies.deny_all 表示 HKLM/HKCU 的全局拒绝访问。HKCU 仅指接收端运行账户;其他驱动限制及域策略仍可能覆盖。portable 不接受 read_only。
policy 和 eject 要求管理员接收端,失败以正常 RPC 错误返回安卓,不弹出授权窗口。mode=allow 恢复 LanCmd 首次修改前的值,不清除预先存在的策略;无管理记录时不写入。修改按设备类别应用,断线及重启后保留。恢复记录 device-policy.json 需随原配置保留;外部策略冲突时拒绝继续写入。策略保存返回 policies/notice,需重新插拔设备,必要时重启。部分固定类型 USB 硬盘不受可移动磁盘策略限制。
eject 重新枚举并验证 ID,仅允许当前列表中可弹出且非系统设备,调用 Windows 配置管理器并提供 veto 输出,设备忙时返回错误,不显示 PnP 拒绝弹窗、不强制卸载。成功返回 ejected/notice。安卓确认与操作绑定原连接,不随重新连接或切换电脑迁移。
apps 默认 action=list 返回 items[{handle,pid,title,name,minimized}];activate/minimize/close 必须提供当前列表中的 handle 字符串与 pid 整数。关闭为 WM_CLOSE,非强制终止;前台切换受 Windows 限制。
files 提供 action=open/preview/extract 与 path。打开使用 Windows 默认 open 动词;预览返回 kind=text/image/archive,对应 text/encoding/truncated、base64 data、或 items/count/truncated。解压仅 ZIP,destination 为新目录,成功返回 path/count/bytes;不覆盖已有目标,拒绝越界、链接、加密和不兼容 Windows 的路径,限制 2000 项、512 MB。
commands 默认 action=list 返回当前 client_id 的 batches;action=add 提供 name 与 items[{line,shell,delay}],每批 1–50 条、每条等待 0–86400 秒,shell 为 cmd/powershell。第一条从启动开始等待,后续从前一条结束后等待,失败继续下一条。每条最多执行 300 秒;批次含 id/created/finished/items,每项含 status、due、started、finished、result 或 error。状态为 pending/waiting/running/completed/failed/cancelled。action=cancel,batch_id 取消尚未开始的项,不撤销 running 项。最多同时运行 4 批,结果 stdout/stderr 各截断 8192 字;手机断线不取消,接收端退出不持久化。
local_input 的 pause/status 新增 touch_devices。capabilities 的 touch_pause 表示接收端支持标准 HID 触屏临时暂停;触屏存在但无法识别或禁用时失败,不降级为仅键鼠暂停。触屏独立恢复进程监视原进程管道与心跳,在解除、管道结束或 6 秒无心跳时重新启用本次禁用的设备,不设持久禁用标记。输入会话原 12 秒心跳恢复与本机快捷键仍适用。
recordings actions: devices, list, start (mode: audio/screen/camera, audio: bool, microphone: -1 default or device id, camera: id, seconds: 1..3600), stop/delete (recording_id). Receiver-generated filenames, owner client_id checks, max 3 recordings and 200 records per owner. Files persist locally, no automatic deletion.
gestures: read-only dimensions returns virtual desktop width/height. Other actions require input-session sid: play (delay: 0..86400, events: 1..6000 {ms,action,x,y}), status, cancel. Events are move/down/up, normalized finite coordinates, monotonic integer milliseconds <=300000 and balanced left-button down/up. Exclusive remote pointer reservation; session heartbeat <12 seconds; cancel on session end. No Windows privacy permissions or indicators are changed.
files adds text_read (encoding: auto or explicit) and text_create/text_write (text, encoding, newline, revision required on write). Bounded to 512 KiB, exclusive create, optimistic content hash, Windows ReplaceFile. Encoding IDs: utf-8, utf-8-bom, gbk, gb18030, utf-16-le/be; newline preserve/crlf/lf/cr.
scripts: run(path), list, cancel(job_id); BAT/CMD/VBS only, owner client_id, 4 concurrent, 300 seconds, 8 KiB per output stream. tasks: list/detail(pid)/terminate(pid,created). app_locks: list/lock(path)/unlock(lock_id)/forget(lock_id), selected EXE execute ACL journal with conflict checks.
registry: root HKCU/HKLM/HKCR/HKU/HKCC, path, view 32/64; browse with key_offset/value_offset pages of 100; get(name); set(name,value,revision); delete_value(name,revision); create_key(child); delete_key(empty only); history/restore(backup_id). Value is {type,data}; integers and binary use strings; MULTI_SZ uses array. Missing value revision is missing.
browser: list/open(url,browser=default or fresh inventory ID), HTTP(S) only. privacy_devices: list; set_enabled(device_id,enabled), admin; mute(device_id,muted), capture endpoints only. Actual permissions, system indicators and hardware lights are unchanged.
Request envelope fields id (numeric correlation ID) and cmd are reserved. Entity IDs in response items remain id; send them back through the action-specific parameter (recording_id, job_id, lock_id, backup_id, or device_id).
Windows advertises placeholders. create(path,size) accepts integer bytes 0..500000000000 inclusive (decimal GB), returns job; list returns owner-scoped items, max_bytes, reserve_bytes; cancel(job_id) requests cancellation and returns cancel_requested. Jobs contain id/path/size/written/allocated/status/created and finished/error when applicable. States: queued/writing/verifying/completed/failed/cancelled. One allocation runs per receiver; successful files persist, in-memory history retains up to 100 entries until receiver restart. Client disconnect does not cancel creation. New files only, local ordinary directories, hidden+system attributes, non-sparse/non-compressed allocation verified after real writes, 1 GB free-space reserve. Uncommitted native files are delete-pending and removed when the process handles close. ls adds boolean hidden/system and continues listing such files.
devices adds force_disconnect(device_id,confirm_data_loss=true) and restore_connection(device_id), both administrator only. Force selects a freshly enumerated, ejectable USB storage disk with protected=false; native disk setup class/USB ancestry also checked. Only the disk node is disabled with CM_DISABLE_UI_NOT_OK (temporary), never its hub/controller. Boot/system/pagefile disks and the receiver/recovery-record drive are excluded. Matching placeholder jobs must stop before disabling. A durable usb-disconnects.json record precedes disable and enables restoration after receiver restart. list adds disconnected with recorded device metadata, actual enabled/problem or error. Actual status 22 confirms disabled, enabled+problem0 confirms restoration; unsupported drivers or uncertain states return errors. This can interrupt writes and corrupt data, does not guarantee physical power-off, and is never an automatic fallback from a vetoed eject.
Android internal Activity transitions preserve pinned sharing sessions and send keepalives while frame polling is suspended; returning resumes capture. Leaving the app (700 ms handoff grace), finishing the owner, explicit stop, or changing the originating connection still ends sharing. Camera preview waits while this client's camera recording is active.
local_input pause/status adds keyboard_mouse, touch_detected, touch_already_disabled, and warning; touch_devices remains the number disabled by this pause. A zero detected count does not assert that vendor-specific touch is blocked. HID probing is independent of SM_DIGITIZER; recognized devices must report problem 22 after disable and enabled/problem0 after restoration. Only devices disabled by this worker are restored. Touch recovery errors are returned as warnings with paused=false, and a pending recovery prevents a new pause. Remote tagged input does not run on the low-level hook's message-pump thread. Existing ownership, zero-only seconds, 12-second session heartbeat and independent recovery watchdog remain unchanged.
ls 每项增加 file_id(基于设备、文件 ID、修改时间、大小、类型的 SHA256)与 link,目录响应也包含 file_id。download.begin 可带 file_id,开始与每次读取核对该版本;不匹配关闭会话并报错。rm 可带 file_id。
file_jobs 仅 Windows,绑定已连接的 client_id:
action=list:返回该手机最近 5 个jobs和恢复warning。action=create, operation=copy|move|delete, items=[{path,file_id}], destination:每批 1–100 个绝对路径,复制/移动必须指定已有目标目录;返回job。每个根最多 20000 项,拒绝链接/重解析点,不覆盖同名目标,复制须保留 1 GB 可用空间。action=cancel, job_id:停止未完成步骤;已发布副本或已删除项目不可撤销。离开安卓页面不自动取消 Windows 任务。- 每任务含
id,operation,status,created,finished?,items,每项含path,file_id,status,bytes?,total_bytes?,destination?,error?,cleanup_warning?。跨卷移动复制完成后源移除失败时状态为 failed、copied=true,目标副本保留。 - 临时副本写入前持久化临时目录身份,重启恢复时仅清理身份一致的本应用临时目录。已完成任务仅保留到接收端退出。
capabilities.features 增加 file_jobs 与 usb_connection;devices.list 增加 actions,包含支持的 action。安卓优先采用动作列表,兼容 2.5/2.6 的版本字段;旧接收端或旧模块不支持时明确提示完整更新并重启,不重试为其他禁用方式。
file_schedule:add 含 command,params,delay(0–86400 整数秒),白名单为 files/rm/rename/mkdir/put/file_jobs.create/placeholders.create/scripts.run,返回 job;get,job_id 返回状态和完成 result;list 返回本手机最近20项元数据;cancel,job_id 仅取消等待项。每次接收端最多20项等待/运行、保留50项,退出不续跑。对所选已存在源保存并重新验证 file_id。批量作业创建延迟结束后还需按原 file_jobs 接口查看执行结果。
files.open 可带 application=default|wps,background=bool,请求后台时使用 SW_SHOWNOACTIVATE 并将新建且同 PID 的窗口置于原前台窗口下方;单实例复用和应用自行激活不保证遵守。files.mtime 含 modified Unix秒,范围1970–2100,保留 atime,可带 file_id。
upload.begin 可带 file_id,只允许覆盖该版本,end 提交前再次检查;冲突删除临时上传,保留电脑原件。成功返回新的 file_id。手机 Office 副本通过受限 FileProvider 的 content URI 向办公应用授权读写,明确确认后回传。
capabilities.features 增加 privacy_device_recovery。privacy_devices.set_enabled(false) 在硬件变更前释放 LanCmd 相关摄像头会话和录制并等待;不处理其他应用。常规 CM 接口在 0x17/0x28/0x13 时尝试所选设备的 SetupAPI DIF_PROPERTYCHANGE,验证 Camera/Image/捕获 AudioEndpoint 类别并设置 DI_QUIETINSTALL,不操作父设备。权限不足不进入备用流程。
成功返回 changed=true,method,enabled,problem,released={camera_sessions?,recordings?},notice,状态必须已确认。驱动要求重启且尚未切换时返回 changed=false,pending_reboot=true,notice,不会自动重启。释放或驱动操作失败返回错误,安卓刷新核对状态并在原设备卡片保留结果。
file_search 绑定当前接收端,能力字段包含 file_search。
status:index={available,count,roots,updated,skipped,incomplete},job?,drives,can_cancel,drives 默认仅本地固定磁盘。build,roots:[绝对目录]:1–32 个目录,合并重叠范围;异步扫描属性,返回 job。状态 building/completed/cancelled/failed,phase scanning/optimizing;每次最多一项建立任务,最多200万条,保留1GB空闲。手机断线继续,重启不续建,已完成缓存保留。cancel,job_id:仅创建任务的手机可取消。取消/失败不替换旧索引。query,query,scope=name|path,kind=all|files|folders,sort=name|path|modified|size,offset,limit:关键词最多256字符、12个词,支持双引号短语和*、?,每页1–100项;返回 items(path/name/parent/dir/size/mtime/file_id),total,offset,limit,index。读取缓存不访问文件内容,未建立时返回空结果和 available=false。索引文件变化需手动重建,操作原件仍须校验 file_id。
能力新增 placeholders_fast,usb_connection_fallback。占位任务新增状态 allocating、method=preallocate|stream;written 表示已处理/预分配字节,完成时仍返回核实的 allocated。快速路径按最多16GiB分段设置 FileAllocationInfo 与 FileEndOfFileInfo,不调用 SetFileValidData 或稀疏接口;仅明确不支持或分配量未确认时清理并回退流式写入。磁盘满与权限失败直接报错,保留原取消及清理行为。
USB 恢复记录新增 config_restore 布尔值,表示兼容停用可能留下的配置必须恢复。记录先于任何设备变更持久化。兼容路径仅 DiskDrive 类,DIF_PROPERTYCHANGE 作用于当前硬件配置,设置 DI_QUIETINSTALL。驱动要求重启而状态未确认时返回错误并保留记录;restore_connection 对 config_restore=true 的记录始终恢复配置,即使运行时设备仍启用,重启仍待完成时不删除记录。
capabilities.features 新增 app_control, app_control_bind, app_hidden, dates_batch, self_manage, self_rename, self_delete, tunnel。以下命令全部要求已握手,均为 Windows 专用。
action=list:返回windows[](handle,pid,title,name,path,visible,minimized,profile)、profiles[](id,label,actions[{id,label,keys}])与hidden[](handle,pid,title,name,path,hidden_at)。profile为空表示不在预设表里。action=act, handle, pid, name, mode=message|input, keys?:name为预设动作 (page_next,page_prev,first,last,pen,eraser,marker,select,blackboard,save,undo,bold, find,slideshow,exit),keys给出时按自定义组合键解析并覆盖预设。mode=message用PostMessage投递,mode=input先切前台再用SendInput。 返回handle,pid,name,action,mode,keys。action=focus, handle, pid:还原(必要时)并切到前台。action=send, handle, pid, text, enter=true:切前台 → 写剪贴板 →Ctrl+V→ 可选回车, 结束后尽量还原原剪贴板文本;text1–2000 字符。action=hide, handle, pid:ShowWindow(SW_HIDE),进程继续运行;返回handle,hidden。 最多 64 个;记录写入%APPDATA%\LanCmd\app-control-hidden.json,接收端退出、升级或自我维护前自动restore_all,被强制结束时下次启动按handle+pid核对后恢复。action=show, handle/action=hidden/action=restore_all:恢复或列举隐形窗口。action=bind, profile, name, keys:写%APPDATA%\LanCmd\app-control.json覆盖预设, 返回合并后的profiles。按键名与input命令一致(CTRL/ALT/SHIFT/WIN/F1–F12/ PAGEDOWN/...,字母数字直接写)。
action=preview, paths[], recursive, mask, include_self:返回count,bytes,sample[]。action=apply, paths[], recursive, mask, include_self, time或start,end:逐个文件 先写恢复记录再改 mtime;固定时间精确匹配,区间内按序号散列取秒。返回id,applied,failed,target,errors[]。文件系统不能精确保存时自动恢复原值并计为失败。action=records/record,id/delete_record,id:列举、查看与删除恢复记录。action=restore, id:仅当身份、大小与当前 mtime 等于本次写入值时还原原日期, 返回restored,skipped,errors[]。- 限制:单次最多 100 个路径、20000 个文件;拒绝磁盘根目录、UNC、系统与程序目录、
符号链接与目录联接;
include_self允许把接收端安装目录纳入范围。
action=status:返回root,config,pid,journal_dir,pending[](未留下完成记录的维护计划)。action=rename, name, confirm=RENAME:校验同父目录、保留名、目标不存在后, 写计划 → 回包 → 1.2 秒后本进程os._exit;助手等待退出、结束本目录其他进程、 改名、改写属于本目录的Run值、从新路径重启。返回accepted,journal,target。action=delete, keep_config, confirm=DELETE:结束自启动项(仅本目录)、递归删除安装目录,keep_config=false时一并删除%APPDATA%\LanCmd。- 计划文件
%LOCALAPPDATA%\LanCmdMaintenance\plan-<时间>.json,执行日志同目录remote-<时间>.jsonl(started/terminated/renamed/startup_repointed/relaunched/ deleted/failed/abort等事件)。助手脚本与载荷写在%TEMP%\LanCmdSelf, 执行结束自行删除。
action=status:running,connected,pid,uptime,endpoint,failures,last_error,log[], providers[],config(config.token返回********)。action=save其余字段provider,server_addr,server_port,token,proxy,remote_port, local_port,config_text,tls,auto_start,enabled:校验后保存并(原运行中则重启)生效。action=start|stop|restart:启动需存在frpc(配置路径、接收端目录或frp/子目录), 按frpc -v选择 TOML(≥0.52)或 INI;输出写入%APPDATA%\LanCmd\tunnel.log, 异常退出退避重启,连续 6 次失败后停止。action=probe:ChmlFrp v2GET {api}/nodeinfo?token&node, 返回node,ip,port,state,version,area,endpoint;自建 frps 不支持查询。- 手机连接方式不变:用
节点地址:远端端口作为手动地址握手。
announcements 的 config 新增 style:
"classic"(默认):沿用原有字段,位置、尺寸、配色、字体、动效全部可调。"seewo":锁定的一体机通知条。接收端在validate()里强制重写mode=ticker, motion=left, position=top, shape=rounded, bold=true, font=Microsoft YaHei UI, background=#12324F, foreground=#FFFFFF, accent=#8FD8FF, width=100, font_size=22, speed=132, opacity=96, 并把placement设为preset、rect清空;自定义位置一律忽略。
可编辑字段仅剩 text、prefix、duration、repeats。prefix 为空时不画徽标列与分隔线,
正文视口左移。手机端切换样式时发送 style=seewo 加上上表的值;关闭时发 style=classic。
样式对应的窗口矩形:宽 min(1760, 可用宽−48) + 16、高 72、顶部偏移 12,全部按
dpi/96 取整;矩形含 8 像素透明阴影留白,GetWindowRect 与手机显示的框一致。
尺寸表的唯一来源是 windows/announcement_seewo.py,安卓镜像在
AnnouncementSeewo.kt;tools/test_announcement_seewo.py 断言两侧常量一致。
style="seewo" 的锁定值在 3.18.1 有变化(3.18.0 的圆角浮动条已废弃):
shape=rectangle, bold=false, opacity=100, background=#020914, foreground=#FFFFFF, accent=#559BE2,并且 font_size / speed / width / placement 对它不再生效——条的位置、
尺寸、字号与速度全部由屏幕可用高度推导:
| 量 | 规则(H = 可用高度,W = 可用宽度) |
|---|---|
| 窗口 | x=可用x, y=可用y+round(10H/360), w=W, h=max(36, round(52H/360)) |
| 字号 | max(12, round(19.5H/360)) |
| 图标 | 左内边距 round(19H/360),边长 round(20H/360),描边 2H/360 |
| 文字视口 | 起点 图标右 + round(8H/360),右端留 round(19H/360) |
| 速度 | 2.4 × 字号 像素/秒 |
| 重复间隔 | 3 × 字号 像素 |
prefix 结尾统一补一个全角冒号(已有则不重复)。前缀与正文是同一行,前缀用 accent 色,
正文用 foreground 色,整行一起滚动。
- 新增
config.messages: string[](≤30 条、每条 ≤500 字)。非空时逐条轮巡;为空退回text。 第一条同时写进text,旧接收端仍能显示。
3.18.2 把前缀和正文当成一整行滚,是错的。3.18.3 拆成两个盒子:
prefix:喇叭右侧的蓝色「消息提醒:」,固定不动,宽度 =advance(prefix, font)。viewport:正文轨道,x = 前缀右缘 + 0.6 em,右端到屏宽 − 19/360·H。- 正文
offset(t) = viewport.width − t × speed:从轨道右端进入,匀速左移, 越过前缀后被clip裁掉;duration = (viewport.width + estimate(body) × 1.05) / speed之后换下一条(或同一条重新从右端进来)。没有停顿。 cycles(repeats计数)按轮计,所有消息各横穿一遍为一轮。- 边界:
locate()用 1 µs 容差,时刻正好落在切换点时归下一条。