服务端采用rust 语言开发,客户端采用 flutter开发,windows 客户端依赖 vcpkg 界面功能。
构建开发容器,可以直接在codespaces中运行:
.devcontainer\Dockerfile
# 安装依赖
RUN sudo apt update -y && sudo apt install -y g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake unzip zip sudo libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
# 安装 vcpkg
RUN git clone https://github.com/microsoft/vcpkg
WORKDIR vcpkg
RUN git checkout 2023.04.15
RUN /vcpkg/bootstrap-vcpkg.sh -disableMetrics
ENV VCPKG_ROOT=/vcpkg
# 安装 rust
RUN wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
RUN chmod +x rustup.sh
RUN $HOME/rustup.sh -y
# 安装flutter 3.10.1
RUN wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.10.1-stable.tar.xz
RUN tar xf flutter_linux_3.10.1-stable.tar.xz && rm flutter_linux_3.10.1-stable.tar.xz
ENV PATH="$PATH:$HOME/flutter/bin"
在 .devcontainer\devcontainer.json 配置镜像,并设置初始化脚本 .devcontainer\build.sh ,以及默认插件,默认执行:
build(){
pwd
$WORKDIR/entrypoint $1
}
构建镜像较久,首次启动会很慢。
配置国内镜像:
RUN sed -i "s/deb.debian.org/mirrors.163.com/g" /etc/apt/sources.list
RUN sed -i "s/security.debian.org/mirrors.163.com/g" /etc/apt/sources.list
RUN echo '[source.crates-io]' > ~/.cargo/config \
&& echo 'registry = "https://github.com/rust-lang/crates.io-index"' >> ~/.cargo/config \
&& echo '# 替换成你偏好的镜像源' >> ~/.cargo/config \
&& echo "replace-with = 'sjtu'" >> ~/.cargo/config \
&& echo '# 上海交通大学' >> ~/.cargo/config \
&& echo '[source.sjtu]' >> ~/.cargo/config \
&& echo 'registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"' >> ~/.cargo/config \
&& echo '' >> ~/.cargo/config
ENV http_proxy=http://host:port
ENV https_proxy=http://host:port
构建和运行:
docker build -t "rustdesk-builder" . --build-arg http_proxy=http://host:port --build-arg https_proxy=http://host:port
# 启动 rustdesk-builder 容器构建
docker run --rm -it -v $PWD:/home/user/rustdesk -v rustdesk-git-cache:/home/user/.cargo/git -v rustdesk-registry-cache:/home/user/.cargo/registry -e PUID="$(id -u)" -e PGID="$(id -g)" rustdesk-builder
# 运行
./target/debug/rustdesk
git clone https://github.com/rustdesk/rustdesk # 克隆Github存储库
cd rustdesk # 进入文件夹
docker build -t "rustdesk-builder" . # 构建容器
docker run --rm -it -v $PWD:/home/user/rustdesk -v rustdesk-git-cache:/home/user/.cargo/git -v rustdesk-registry-cache:/home/user/.cargo/registry -e PUID="$(id -u)" -e PGID="$(id -g)" rustdesk-builder
跨平台项目一般都在Linux上开发,可以依照 dockerfile 中参考,安装并构建: 主要依赖git,rust,flutter,ndk,sciter,vcpkg(音视频)
sudo apt install ca-certificates -y
sudo apt update -y
sudo apt install -y zip g++ gcc git curl wget nasm yasm libgtk-3-dev clang cmake libclang-dev ninja-build llvm-dev libclang-10-dev llvm-10-dev pkg-config libxcb-randr0-dev libxdo-dev \
libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev make \
libgstreamer1.0-dev libgstreamer-plu
git clone https://github.com/microsoft/vcpkg
cd vcpkg
git checkout 2023.04.15
cd ..
vcpkg/bootstrap-vcpkg.bat
export VCPKG_ROOT=$PWD/vcpkg
vcpkg/vcpkg install libvpx:x64-windows-static libyuv:x64-windows-static opus:x64-windows-static aom:x64-windows-static
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup --version
# rust自动生成dart代码
cargo install flutter_rust_bridge_codegen --version 1.75.3 --features uuid
#flutter_rust_bridge_codegen create demo #创建项目
# ~\.cargo\bin\flutter_rust_bridge_codegen.exe --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart --llvm-path=E:\Data\LLVM
git clone https://github.com/rustdesk/rustdesk
cd rustdesk
mkdir -p target/debug
wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll
mv sciter.dll target/debug
cargo install
VCPKG_ROOT=$HOME/vcpkg cargo run
flutter_rust_bridge_codegen pushd flutter && flutter pub get && popd
flutter build apk --target-platform android-arm64
flutter build windows
也可以在windows开发,安装rust,flutter,Android,vs,vcpkg(C++)等:
修改id 服务器 libs/hbb_common/src/config.rs :
id_server = "127.0.0.1:8080"
relay_server = "127.0.0.1:8080"
api_server = "127.0.0.1:8081"
key = "key"
编译windows:
# windows打包
cargo build --release
PS C:\Users\Administrator> $env:PATH += ";E:\Data\LLVM\lib"
PS C:\Users\Administrator> $env:PATH += ";E:\Data\flutter\flutter_windows_3.13.1-stable\flutter\bin"
dart pub upgrade
flutter build windows
libs/hbb_common: 视频编解码, 配置, tcp/udp 封装, protobuf, 文件传输相关文件系统操作函数, 以及一些其他实用函数
libs/scrap: 屏幕截取
libs/enigo: 平台相关的鼠标键盘输入
src/ui: GUI
src/server: 被控端服务音频、剪切板、输入、视频服务、网络连接的实现
src/client.rs: 控制端
src/rendezvous_mediator.rs: 与rustdesk-server保持UDP通讯, 等待远程连接(通过打洞直连或者中继)
src/platform: 平台服务相关代码
flutter: 移动版本的Flutter代码
flutter/web/js: Flutter Web版本中的Javascript代码