f8ead215d8
build-windows / build-hello-agent-x64 (push) Successful in 5m41s
A single-binary, Flutter-free remote-support agent that speaks the stock
RustDesk wire protocol. Designed for one-line MDM deployment against a
self-hosted rustdesk-server: a supporter using the unmodified rustdesk.exe
client connects, the controlled-side user gets a native Win32 approval
prompt, click Yes / No.
CLI surface
hello-agent.exe --install # register + start service
hello-agent.exe --uninstall # stop, delete, clean up
hello-agent.exe --config <BLOB> # admin-UI deploy string
hello-agent.exe --install --config <BLOB> # MDM one-liner
--config accepts both forms emitted by the rustdesk-server admin UI: the
reversed-base64 deploy string and the host=,key=,api=,relay= filename
form. Decoded via the upstream custom_server module, persisted via
hbb_common::config::Config::set_option.
Architecture
--service runs as a Session 0 LocalSystem service. It polls
WTSGetActiveConsoleSessionId and (re)spawns hello-agent.exe --server
into the active console session via librustdesk::platform::run_as_user,
handling the Session 0 → user-session token impersonation.
--server is the worker. It boots three concurrent components:
1. cm_popup: an IPC listener on the rustdesk `_cm` named pipe
2. librustdesk::start_server(true, false): the upstream protocol
stack — rendezvous mediator, NAT punch, IPC server, screen
capture, login validation, hbbs_http heartbeat / sysinfo sync
3. (implicit) ApproveMode::Click is pinned in config, so every
incoming connection routes through cm_popup
The popup mechanism reuses an existing upstream contract without any
patches to the protocol code: when a peer connects with no password,
Connection::start in the upstream code calls try_start_cm_ipc, which
ipc::connect-s the `_cm` pipe before falling back to spawning a Flutter
CM child. Since cm_popup is up first, step 1 succeeds; we read the
Data::Login{authorized:false} frame, show MessageBoxTimeoutW (Yes/No,
60s, top-most, system-modal), and reply Data::Authorize or Data::Close.
Source tree
src/main.rs CLI dispatcher + run_server() composition
src/cli.rs hand-rolled argv parser + unit tests
src/service.rs windows-service install/uninstall/dispatcher
src/config_import.rs --config blob decoding + persistence
src/cm_popup.rs _cm IPC listener + Win32 approval dialog
Vendoring
The upstream RustDesk crate is vendored under vendor/rustdesk/ — full
workspace including libs/{hbb_common, scrap, enigo, clipboard,
virtual_display, remote_printer}. This makes the build self-contained
(no submodules, no sibling-repo checkout in CI) and gives us freedom to
fork in a different direction later. Excluded from the vendor: .git,
target/, flutter/, appimage/, flatpak/, fastlane/, docs/, examples/,
ci/, build.py, Dockerfile, upstream README/CLAUDE/AGENTS/GEMINI.
One local divergence vs. upstream: vendor/rustdesk/src/lib.rs flips
`mod custom_server` → `pub mod custom_server` so config_import.rs can
call get_custom_server_from_string without going through the
ui_interface shim. Documented in README.md → "Re-syncing the vendored
copy".
CI
.gitea/workflows/build-windows.yml builds on a self-hosted Windows
runner with Rust 1.75, LLVM 15.0.6 (libclang for bindgen via libvpx-sys),
and a vcpkg cache. The vendored vcpkg.json drives x64-windows-static
deps. The workflow stages the resulting hello-agent.exe into
SignOutput\, reports authenticode signing status (warns on unsigned),
and uploads as artifact. ~15 min full build, faster on incremental.
Out of scope for this commit: Linux/macOS builds, code signing, MSI
packaging, coexistence with stock rustdesk on the same box (currently
shares the RustDesk APP_NAME and config dir).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
83 lines
3.1 KiB
Python
83 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import re
|
|
|
|
|
|
def strip(s): return re.sub(r'\s+\n', '\n', re.sub(r'\n\s+', '\n', s))
|
|
|
|
common_css = open('src/ui/common.css').read()
|
|
common_tis = open('src/ui/common.tis', encoding='UTF8').read()
|
|
|
|
index = open('src/ui/index.html').read() \
|
|
.replace('@import url(index.css);', open('src/ui/index.css').read()) \
|
|
.replace('include "index.tis";', open('src/ui/index.tis').read()) \
|
|
.replace('include "msgbox.tis";', open('src/ui/msgbox.tis').read()) \
|
|
.replace('include "ab.tis";', open('src/ui/ab.tis').read())
|
|
|
|
remote = open('src/ui/remote.html').read() \
|
|
.replace('@import url(remote.css);', open('src/ui/remote.css').read()) \
|
|
.replace('@import url(header.css);', open('src/ui/header.css').read()) \
|
|
.replace('@import url(file_transfer.css);', open('src/ui/file_transfer.css').read()) \
|
|
.replace('include "remote.tis";', open('src/ui/remote.tis').read()) \
|
|
.replace('include "msgbox.tis";', open('src/ui/msgbox.tis').read()) \
|
|
.replace('include "grid.tis";', open('src/ui/grid.tis').read()) \
|
|
.replace('include "header.tis";', open('src/ui/header.tis').read()) \
|
|
.replace('include "file_transfer.tis";', open('src/ui/file_transfer.tis').read()) \
|
|
.replace('include "port_forward.tis";', open('src/ui/port_forward.tis').read()) \
|
|
.replace('include "printer.tis";', open('src/ui/printer.tis').read())
|
|
|
|
chatbox = open('src/ui/chatbox.html').read()
|
|
install = open('src/ui/install.html').read().replace('include "install.tis";', open('src/ui/install.tis').read())
|
|
|
|
cm = open('src/ui/cm.html').read() \
|
|
.replace('@import url(cm.css);', open('src/ui/cm.css').read()) \
|
|
.replace('include "cm.tis";', open('src/ui/cm.tis').read())
|
|
|
|
|
|
def compress(s):
|
|
s = s.replace("\r\n", "\n")
|
|
x = bytes(s, encoding='utf-8')
|
|
return '&[u8; ' + str(len(x)) + '] = b"' + str(x)[2:-1].replace(r"\'", "'").replace(r'"',
|
|
r'\"') + '"'
|
|
|
|
|
|
with open('src/ui/inline.rs', 'wt') as fh:
|
|
fh.write('const _COMMON_CSS: ' + compress(strip(common_css)) + ';\n')
|
|
fh.write('const _COMMON_TIS: ' + compress(strip(common_tis)) + ';\n')
|
|
fh.write('const _INDEX: ' + compress(strip(index)) + ';\n')
|
|
fh.write('const _REMOTE: ' + compress(strip(remote)) + ';\n')
|
|
fh.write('const _CHATBOX: ' + compress(strip(chatbox)) + ';\n')
|
|
fh.write('const _INSTALL: ' + compress(strip(install)) + ';\n')
|
|
fh.write('const _CONNECTION_MANAGER: ' + compress(strip(cm)) + ';\n')
|
|
fh.write('''
|
|
fn get(data: &[u8]) -> String {
|
|
String::from_utf8_lossy(data).to_string()
|
|
}
|
|
fn replace(data: &[u8]) -> String {
|
|
let css = get(&_COMMON_CSS[..]);
|
|
let res = get(data).replace("@import url(common.css);", &css);
|
|
let tis = get(&_COMMON_TIS[..]);
|
|
res.replace("include \\\"common.tis\\\";", &tis)
|
|
}
|
|
#[inline]
|
|
pub fn get_index() -> String {
|
|
replace(&_INDEX[..])
|
|
}
|
|
#[inline]
|
|
pub fn get_remote() -> String {
|
|
replace(&_REMOTE[..])
|
|
}
|
|
#[inline]
|
|
pub fn get_install() -> String {
|
|
replace(&_INSTALL[..])
|
|
}
|
|
#[inline]
|
|
pub fn get_chatbox() -> String {
|
|
replace(&_CHATBOX[..])
|
|
}
|
|
#[inline]
|
|
pub fn get_cm() -> String {
|
|
replace(&_CONNECTION_MANAGER[..])
|
|
}
|
|
''')
|