天问

rustdesk开发教程

rustdesk

Open source virtual / remote desktop infrastructure for everyone! The open source TeamViewer alternative. Display and control your PC and Android devices from anywhere at anytime.

Develop

包含服务端和client

pc 客户端,Desktop versions use Sciter for GUI

 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
 ​
 ​
 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 run
 ​

Android:

需要ndk,flutter,Rust,https://rustdesk.com/docs/en/dev/build/android/

 # 编译生成 generated_bridge
 cd rustdesk
 git clone https://github.com/rustdesk/rustdesk
 ​
 sudo apt install ca-certificates -y
 sudo apt update -y
 sudo apt install -y 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
 ​
 ​
 cargo install flutter_rust_bridge_codegen
 pushd flutter && flutter pub get && popd
 ​
 ~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
 ​
 # 编译flutter项目
 sudo apt update -y
 sudo apt-get -qq install -y 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 libclang-dev ninja-build libappindicator3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libvdpau-dev libva-dev libclang-dev llvm-dev libclang-10-dev llvm-10-dev pkg-config tree g++ libc6-dev gcc-multilib g++-multilib openjdk-11-jdk-headless
 ​
 dart pub global activate ffigen 5.0.1
 ​
 pushd /opt
 sudo wget https://github.com/rustdesk/doc.rustdesk.com/releases/download/console/dep.tar.gz
 sudo tar xzf dep.tar.gz
 popd
 ​
 ​
 ​

服务端:

  • hbbs- RustDesk ID/Rendezvous 服务器
  • hbbr- RustDesk 中继服务器

开放端口: TCP(21115、21116、21117、21118、21119)

UDP ( 21116 )

其中hbbs侦听 21115 (TCP)、21116 (TCP/UDP) 和 21118 (TCP),hbbr侦听 21117 (TCP) 和 21119 (TCP)

先安装依赖:

 sudo apt install -y zip 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 make \
        libclang-dev ninja-build libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
 ​
 # 或者yum
 sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-devel libxdo-devel libXfixes-devel pulseaudio-libs-devel cmake alsa-lib-devel
 ​
 # 安装vcpkg
 git clone https://github.com/microsoft/vcpkg
 cd vcpkg
 git checkout 2023.04.15
 cd ..
 vcpkg/bootstrap-vcpkg.sh
 export VCPKG_ROOT=$HOME/vcpkg
 vcpkg/vcpkg install libvpx libyuv opus aom

源码编译:

 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
 source $HOME/.cargo/env
 git clone https://github.com/rustdesk/rustdesk
 cd rustdesk
 mkdir -p target/debug
 wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so
 mv libsciter-gtk.so target/debug
 VCPKG_ROOT=$HOME/vcpkg cargo run

编译环境很多,为此可以基于Ubuntu打包一个开发容器来快速编译:

 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
 ​

服务器配置: 2核4G内内存

https://github.com/rustdesk/rustdesk-server/releases/latest
https://rustdesk.com/docs/en/self-host/rustdesk-server-oss/install

release 下载,

 ufw allow proto tcp from YOURIP to any port 22
 ​
 ufw allow 21115:21119/tcp
 ufw allow 8000/tcp
 ufw allow 21116/udp
 sudo ufw enable
 ​
 wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/install.sh
 chmod +x install.sh
 ./install.sh
 ​
 ​
 ./hbbs -r <relay-server-ip[:port]>
 ./hbbr
 ​
 hbbs.example.com:21116
 ​

或者docker安装:

 version: '3'
 ​
 services:
  hbbs:
    container_name: hbbs
    image: rustdesk/rustdesk-server:latest
    command: hbbs
    volumes:
      - ./data:/root
    network_mode: "host"
 ​
    depends_on:
      - hbbr
    restart: unless-stopped
 ​
 ​
  hbbr:
    container_name: hbbr
    image: rustdesk/rustdesk-server:latest
    command: hbbr
    volumes:
      - ./data:/root
    network_mode: "host"
    restart: unless-stopped
 ​

启动服务:

 docker compser -d up
 ​
 # 查询key并记录
 cat ·/data/id_xx.pub
 ​
 docker logs -f hbbs
 ​

然后在客户端配置服务器地址和Key

博客地址:https://blog.yoqi.me/?p=18019
扫我捐助哦
喜欢 1

这篇文章还没有评论

发表评论