Compare commits
38
Commits
master
...
test-v0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb8b5b9cf4 | ||
|
|
f85f6910d2 | ||
|
|
4e63c834f5 | ||
|
|
b5e0484d03 | ||
|
|
eb931f1eaa | ||
|
|
95b18ee1a4 | ||
|
|
5aabb038f4 | ||
|
|
872f1f95c8 | ||
|
|
3d85ecc18e | ||
|
|
f8a6393ea9 | ||
|
|
4ff3d2db9a | ||
|
|
813e78d686 | ||
|
|
2975151e97 | ||
|
|
abb1892af4 | ||
|
|
09ff39cc82 | ||
|
|
379ba44ad9 | ||
|
|
c01ab5621a | ||
|
|
d095ac8cec | ||
|
|
9ee99f1412 | ||
|
|
a11e3636c8 | ||
|
|
ea3d353aa6 | ||
|
|
45c900a7e6 | ||
|
|
8470471e9c | ||
|
|
9416a98e48 | ||
|
|
bc980a3b84 | ||
|
|
42b836d064 | ||
|
|
ec534abc5e | ||
|
|
c72e0dc3e1 | ||
|
|
4e37dc8090 | ||
|
|
e5ac30e2bc | ||
|
|
d793bcf569 | ||
|
|
bb45a621a4 | ||
|
|
14198e7586 | ||
|
|
7ff5eee69b | ||
|
|
b317b9e9e5 | ||
|
|
a2b4e8e4a5 | ||
|
|
10c23984a7 | ||
|
|
9bae660559 |
@@ -0,0 +1,181 @@
|
||||
name: build-test
|
||||
|
||||
# ------------- NOTE
|
||||
# please setup some secrets before running this workflow:
|
||||
# DOCKER_IMAGE should be the target image name on docker hub (e.g. "rustdesk/rustdesk-server-s6" )
|
||||
# DOCKER_IMAGE_CLASSIC should be the target image name on docker hub for the old build (e.g. "rustdesk/rustdesk-server" )
|
||||
# DOCKER_USERNAME is the username you normally use to login at https://hub.docker.com/
|
||||
# DOCKER_PASSWORD is a token you should create under "account settings / security" with read/write access
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- 'test.*'
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
LATEST_TAG: latest
|
||||
|
||||
jobs:
|
||||
|
||||
# binary build
|
||||
build:
|
||||
|
||||
name: Build - ${{ matrix.job.name }}
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- { name: "amd64", target: "x86_64-unknown-linux-musl" }
|
||||
- { name: "arm64v8", target: "aarch64-unknown-linux-musl" }
|
||||
- { name: "armv7", target: "armv7-unknown-linux-musleabihf" }
|
||||
- { name: "i386", target: "i686-unknown-linux-musl" }
|
||||
#- { name: "amd64fb", target: "x86_64-unknown-freebsd" }
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
default: true
|
||||
components: rustfmt
|
||||
profile: minimal
|
||||
target: ${{ matrix.job.target }}
|
||||
|
||||
- name: Build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --all-features --target=${{ matrix.job.target }}
|
||||
use-cross: true
|
||||
|
||||
- name: Exec chmod
|
||||
run: chmod -v a+x target/${{ matrix.job.target }}/release/*
|
||||
|
||||
- name: Publish Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: binaries-linux-${{ matrix.job.name }}
|
||||
path: |
|
||||
target/${{ matrix.job.target }}/release/hbbr
|
||||
target/${{ matrix.job.target }}/release/hbbs
|
||||
target/${{ matrix.job.target }}/release/rustdesk-utils
|
||||
if-no-files-found: error
|
||||
|
||||
|
||||
# docker build and push of single-arch images
|
||||
docker:
|
||||
|
||||
name: Docker push - ${{ matrix.job.name }}
|
||||
needs: build
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- { name: "amd64", docker_platform: "linux/amd64", s6_platform: "x86_64" }
|
||||
- { name: "arm64v8", docker_platform: "linux/arm64", s6_platform: "aarch64" }
|
||||
- { name: "armv7", docker_platform: "linux/arm/v7", s6_platform: "armhf" }
|
||||
# - { name: "i386", docker_platform: "linux/386", s6_platform: "i686" }
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Download binaries
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: binaries-linux-${{ matrix.job.name }}
|
||||
path: docker/rootfs/usr/bin
|
||||
|
||||
- name: Make binaries executable
|
||||
run: chmod -v a+x docker/rootfs/usr/bin/*
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: registry.hub.docker.com/${{ secrets.DOCKER_IMAGE }}
|
||||
|
||||
- name: Get git tag
|
||||
id: vars
|
||||
run: |
|
||||
T=${GITHUB_REF#refs/*/}
|
||||
M=${T%.*}
|
||||
echo "GIT_TAG=$T" >> $GITHUB_ENV
|
||||
echo "MAJOR_TAG=$M" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: "./docker"
|
||||
platforms: ${{ matrix.job.docker_platform }}
|
||||
push: true
|
||||
provenance: false
|
||||
build-args: |
|
||||
S6_ARCH=${{ matrix.job.s6_platform }}
|
||||
tags: |
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-${{ matrix.job.name }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
# docker build and push of multiarch images
|
||||
docker-manifest:
|
||||
|
||||
name: Docker manifest s6
|
||||
needs: docker
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Get git tag
|
||||
id: vars
|
||||
run: |
|
||||
T=${GITHUB_REF#refs/*/}
|
||||
M=${T%.*}
|
||||
echo "GIT_TAG=$T" >> $GITHUB_ENV
|
||||
echo "MAJOR_TAG=$M" >> $GITHUB_ENV
|
||||
|
||||
# manifest for :1.2.3 tag
|
||||
# this has to run only if invoked by a new tag
|
||||
- name: Create and push manifest (:ve.rs.ion)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
tags: ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}
|
||||
inputs: |
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-amd64,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-arm64v8,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-armv7,
|
||||
# ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-i386
|
||||
push: true
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
build:
|
||||
|
||||
name: Build - ${{ matrix.job.name }}
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: "1.81"
|
||||
toolchain: stable
|
||||
override: true
|
||||
default: true
|
||||
components: rustfmt
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
|
||||
build-win:
|
||||
name: Build - windows
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
|
||||
@@ -88,7 +88,7 @@ jobs:
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: "1.81"
|
||||
toolchain: stable
|
||||
override: true
|
||||
default: true
|
||||
components: rustfmt
|
||||
@@ -172,7 +172,7 @@ jobs:
|
||||
needs:
|
||||
- build
|
||||
- build-win
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -212,7 +212,7 @@ jobs:
|
||||
|
||||
name: Docker push - ${{ matrix.job.name }}
|
||||
needs: build
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -220,7 +220,7 @@ jobs:
|
||||
- { name: "amd64", docker_platform: "linux/amd64", s6_platform: "x86_64" }
|
||||
- { name: "arm64v8", docker_platform: "linux/arm64", s6_platform: "aarch64" }
|
||||
- { name: "armv7", docker_platform: "linux/arm/v7", s6_platform: "armhf" }
|
||||
- { name: "i386", docker_platform: "linux/386", s6_platform: "i686" }
|
||||
# - { name: "i386", docker_platform: "linux/386", s6_platform: "i686" }
|
||||
|
||||
steps:
|
||||
|
||||
@@ -283,9 +283,9 @@ jobs:
|
||||
# docker build and push of multiarch images
|
||||
docker-manifest:
|
||||
|
||||
name: Docker manifest
|
||||
name: Docker manifest s6
|
||||
needs: docker
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
|
||||
@@ -308,35 +308,46 @@ jobs:
|
||||
# this has to run only if invoked by a new tag
|
||||
- name: Create and push manifest (:ve.rs.ion)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
with:
|
||||
base-image: ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}
|
||||
extra-images: ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-amd64,${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-armv7,${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-i386
|
||||
tags: ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}
|
||||
inputs: |
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-amd64,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-arm64v8,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-armv7,
|
||||
# ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-i386
|
||||
push: true
|
||||
|
||||
# manifest for :1 tag (major release)
|
||||
- name: Create and push manifest (:major)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
base-image: ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}
|
||||
extra-images: ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-amd64,${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-armv7,${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-i386
|
||||
tags: ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}
|
||||
inputs: |
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-amd64,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-arm64v8,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-armv7,
|
||||
# ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-i386
|
||||
push: true
|
||||
|
||||
# manifest for :latest tag
|
||||
- name: Create and push manifest (:latest)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
base-image: ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}
|
||||
extra-images: ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-amd64,${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-armv7,${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-i386
|
||||
tags: ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}
|
||||
inputs: |
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-amd64,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-arm64v8,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-armv7,
|
||||
# ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-i386
|
||||
push: true
|
||||
|
||||
|
||||
# docker build and push of single-arch images
|
||||
docker-classic:
|
||||
|
||||
name: Docker push - ${{ matrix.job.name }}
|
||||
name: Docker push classic - ${{ matrix.job.name }}
|
||||
needs: build
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -404,10 +415,9 @@ jobs:
|
||||
# docker build and push of multiarch images
|
||||
docker-manifest-classic:
|
||||
|
||||
name: Docker manifest
|
||||
name: Docker manifest classic
|
||||
needs: docker
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
@@ -431,24 +441,24 @@ jobs:
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
with:
|
||||
base-image: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}
|
||||
extra-images: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-amd64,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-armv7
|
||||
tags: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}
|
||||
inputs: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-amd64,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-armv7
|
||||
push: true
|
||||
|
||||
# manifest for :1 tag (major release)
|
||||
- name: Create and push manifest (:major)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
base-image: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}
|
||||
extra-images: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-amd64,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-armv7
|
||||
tags: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}
|
||||
inputs: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-amd64,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-armv7
|
||||
push: true
|
||||
|
||||
# manifest for :latest tag
|
||||
- name: Create and push manifest (:latest)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
base-image: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}
|
||||
extra-images: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-amd64,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-armv7
|
||||
tags: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}
|
||||
inputs: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-amd64,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-armv7
|
||||
push: true
|
||||
|
||||
|
||||
@@ -456,7 +466,7 @@ jobs:
|
||||
|
||||
name: debian package - ${{ matrix.job.name }}
|
||||
needs: build
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
||||
+21
-21
@@ -42,7 +42,7 @@ jobs:
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: "1.70.0"
|
||||
toolchain: stable
|
||||
targets: ${{ matrix.job.target }}
|
||||
components: "rustfmt"
|
||||
|
||||
@@ -72,7 +72,7 @@ jobs:
|
||||
|
||||
# Build and push single-arch Docker images to ghcr.io
|
||||
create-s6-overlay-images:
|
||||
name: Docker push - ${{ matrix.job.name }}
|
||||
name: Docker push s6-overlay - ${{ matrix.job.name }}
|
||||
needs: build
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
- { name: "amd64", docker_platform: "linux/amd64", s6_platform: "x86_64" }
|
||||
- { name: "arm64v8", docker_platform: "linux/arm64", s6_platform: "aarch64" }
|
||||
- { name: "armv7", docker_platform: "linux/arm/v7", s6_platform: "armhf" }
|
||||
- { name: "i386", docker_platform: "linux/386", s6_platform: "i686" }
|
||||
# - { name: "i386", docker_platform: "linux/386", s6_platform: "i686" }
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -171,41 +171,41 @@ jobs:
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
with:
|
||||
base-image: ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}
|
||||
extra-images: |
|
||||
tags: ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}
|
||||
inputs: |
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-amd64,
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-arm64v8,
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-armv7,
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-i386
|
||||
# ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-i386
|
||||
push: true
|
||||
|
||||
# Create and push manifest for :major tag
|
||||
- name: Create and push manifest (:major)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
base-image: ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}
|
||||
extra-images: |
|
||||
tags: ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}
|
||||
inputs: |
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-amd64,
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-arm64v8,
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-armv7,
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-i386
|
||||
# ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-i386
|
||||
push: true
|
||||
|
||||
# Create and push manifest for :latest tag
|
||||
- name: Create and push manifest (:latest)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
base-image: ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}
|
||||
extra-images: |
|
||||
tags: ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}
|
||||
inputs: |
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-amd64,
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-arm64v8,
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-armv7,
|
||||
ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-i386
|
||||
# ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-i386
|
||||
push: true
|
||||
|
||||
# Build and push single-arch Docker images to ghcr.io
|
||||
create-classic-images:
|
||||
name: Docker push - ${{ matrix.job.name }}
|
||||
name: Docker push classic - ${{ matrix.job.name }}
|
||||
needs: build
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
@@ -235,7 +235,7 @@ jobs:
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
@@ -246,7 +246,7 @@ jobs:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
@@ -302,8 +302,8 @@ jobs:
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
with:
|
||||
base-image: ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}
|
||||
extra-images: |
|
||||
tags: ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}
|
||||
inputs: |
|
||||
ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}-amd64,
|
||||
ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}-arm64v8,
|
||||
ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}-armv7,
|
||||
@@ -314,8 +314,8 @@ jobs:
|
||||
- name: Create and push manifest (:major)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
base-image: ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}
|
||||
extra-images: |
|
||||
tags: ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}
|
||||
inputs: |
|
||||
ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}-amd64,
|
||||
ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}-arm64v8,
|
||||
ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}-armv7,
|
||||
@@ -326,8 +326,8 @@ jobs:
|
||||
- name: Create and push manifest (:latest)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
with:
|
||||
base-image: ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}
|
||||
extra-images: |
|
||||
tags: ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}
|
||||
inputs: |
|
||||
ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}-amd64,
|
||||
ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}-arm64v8,
|
||||
ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}-armv7,
|
||||
|
||||
Generated
+1
@@ -342,6 +342,7 @@ dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ async-trait = "0.1"
|
||||
async-speed-limit = { git = "https://github.com/open-trade/async-speed-limit" }
|
||||
uuid = { version = "1.0", features = ["v4"] }
|
||||
bcrypt = "0.13"
|
||||
chrono = "0.4"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
jsonwebtoken = "8"
|
||||
headers = "0.3"
|
||||
once_cell = "1.8"
|
||||
|
||||
@@ -1,3 +1,65 @@
|
||||
|
||||
# About this repository
|
||||
|
||||
[](https://github.com/lejianwen/rustdesk-server/actions/workflows/build.yaml)
|
||||
|
||||
- Solves the issue of connection timeout when the client logs in with an `API` account
|
||||
- Added `API` support to the s6 image, `API` open-source repository: https://github.com/lejianwen/rustdesk-api
|
||||
- Whether login is required to connect, `MUST_LOGIN` defaults to `N`, set to `Y` to require login for connection
|
||||
- `RUSTDESK_API_JWT_KEY`, when set, validates the token's legitimacy through `JWT`
|
||||
|
||||
## docker
|
||||
|
||||
- s6 Image [lejianwen/rustdesk-server-s6](https://hub.docker.com/r/lejianwen/rustdesk-server-s6)
|
||||
|
||||
```yaml
|
||||
networks:
|
||||
rustdesk-net:
|
||||
external: false
|
||||
services:
|
||||
rustdesk:
|
||||
ports:
|
||||
- 21114:21114
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: lejianwen/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- RELAY=<relay_server[:port]>
|
||||
- ENCRYPTED_ONLY=1
|
||||
- MUST_LOGIN=N
|
||||
- TZ=Asia/Shanghai
|
||||
- RUSTDESK_API_RUSTDESK_ID_SERVER=<id_server[:21116]>
|
||||
- RUSTDESK_API_RUSTDESK_RELAY_SERVER=<relay_server[:21117]>
|
||||
- RUSTDESK_API_RUSTDESK_API_SERVER=http://<api_server[:21114]>
|
||||
- RUSTDESK_API_KEY_FILE=/data/id_ed25519.pub
|
||||
- RUSTDESK_API_JWT_KEY=xxxxxx # jwt key
|
||||
volumes:
|
||||
- /data/rustdesk/server:/data
|
||||
- /data/rustdesk/api:/app/data #
|
||||
networks:
|
||||
- rustdesk-net
|
||||
restart: unless-stopped
|
||||
|
||||
```
|
||||
|
||||
- Common Image [lejianwen/rustdesk-server](https://hub.docker.com/r/lejianwen/rustdesk-server)
|
||||
|
||||
|
||||
# API Screenshot
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
More See [RustDesk Api](https://github.com/lejianwen/rustdesk-api)
|
||||
|
||||
|
||||
|
||||
|
||||
<p align="center">
|
||||
<a href="#manuelles-erstellen">Erstellen</a> •
|
||||
<a href="#docker-image">Docker</a> •
|
||||
|
||||
+418
@@ -0,0 +1,418 @@
|
||||
|
||||
# About this repository
|
||||
|
||||
[](https://github.com/lejianwen/rustdesk-server/actions/workflows/build.yaml)
|
||||
|
||||
- Solves the issue of connection timeout when the client logs in with an `API` account
|
||||
- Added `API` support to the s6 image, `API` open-source repository: https://github.com/lejianwen/rustdesk-api
|
||||
- Whether login is required to connect, `MUST_LOGIN` defaults to `N`, set to `Y` to require login for connection
|
||||
- `RUSTDESK_API_JWT_KEY`, when set, validates the token's legitimacy through `JWT`
|
||||
- Support client websocket (client >= 1.4.1)
|
||||
|
||||
## docker
|
||||
|
||||
- s6 Image [lejianwen/rustdesk-server-s6](https://hub.docker.com/r/lejianwen/rustdesk-server-s6)
|
||||
|
||||
```yaml
|
||||
networks:
|
||||
rustdesk-net:
|
||||
external: false
|
||||
services:
|
||||
rustdesk:
|
||||
ports:
|
||||
- 21114:21114
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: lejianwen/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- RELAY=<relay_server[:port]>
|
||||
- ENCRYPTED_ONLY=1
|
||||
- MUST_LOGIN=N
|
||||
- TZ=Asia/Shanghai
|
||||
- RUSTDESK_API_RUSTDESK_ID_SERVER=<id_server[:21116]>
|
||||
- RUSTDESK_API_RUSTDESK_RELAY_SERVER=<relay_server[:21117]>
|
||||
- RUSTDESK_API_RUSTDESK_API_SERVER=http://<api_server[:21114]>
|
||||
- RUSTDESK_API_KEY_FILE=/data/id_ed25519.pub
|
||||
- RUSTDESK_API_JWT_KEY=xxxxxx # jwt key
|
||||
volumes:
|
||||
- /data/rustdesk/server:/data
|
||||
- /data/rustdesk/api:/app/data #
|
||||
networks:
|
||||
- rustdesk-net
|
||||
restart: unless-stopped
|
||||
|
||||
```
|
||||
|
||||
- Common Image [lejianwen/rustdesk-server](https://hub.docker.com/r/lejianwen/rustdesk-server)
|
||||
|
||||
|
||||
# API Screenshot
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
More See [RustDesk Api](https://github.com/lejianwen/rustdesk-api)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p align="center">
|
||||
<a href="#how-to-build-manually">Manually</a> •
|
||||
<a href="#docker-images">Docker</a> •
|
||||
<a href="#s6-overlay-based-images">S6-overlay</a> •
|
||||
<a href="#how-to-create-a-keypair">Keypair</a> •
|
||||
<a href="#deb-packages">Debian</a> •
|
||||
<a href="#env-variables">Variables</a><br>
|
||||
[<a href="README-DE.md">Deutsch</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-TW.md">繁體中文</a>] | [<a href="README-ZH.md">简体中文</a>]<br>
|
||||
</p>
|
||||
|
||||
# RustDesk Server Program
|
||||
|
||||
[](https://github.com/rustdesk/rustdesk-server/actions/workflows/build.yaml)
|
||||
|
||||
[**Download**](https://github.com/rustdesk/rustdesk-server/releases)
|
||||
|
||||
[**Manual**](https://rustdesk.com/docs/en/self-host/)
|
||||
|
||||
[**FAQ**](https://github.com/rustdesk/rustdesk/wiki/FAQ)
|
||||
|
||||
Self-host your own RustDesk server, it is free and open source.
|
||||
|
||||
## How to build manually
|
||||
|
||||
```bash
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
Three executables will be generated in target/release.
|
||||
|
||||
- hbbs - RustDesk ID/Rendezvous server
|
||||
- hbbr - RustDesk relay server
|
||||
- rustdesk-utils - RustDesk CLI utilities
|
||||
|
||||
You can find updated binaries on the [Releases](https://github.com/rustdesk/rustdesk-server/releases) page.
|
||||
|
||||
If you want extra features, [RustDesk Server Pro](https://rustdesk.com/pricing.html) might suit you better.
|
||||
|
||||
If you want to develop your own server, [rustdesk-server-demo](https://github.com/rustdesk/rustdesk-server-demo) might be a better and simpler start for you than this repo.
|
||||
|
||||
## Docker images
|
||||
|
||||
Docker images are automatically generated and published to [Docker Hub](https://hub.docker.com/r/rustdesk) and [GitHub Container Registry](https://github.com/rustdesk?tab=packages&repo_name=rustdesk-server) on every GitHub release. We have 2 kind of images.
|
||||
|
||||
### Classic image
|
||||
|
||||
These images are built from scratch with two main binaries (`hbbs` and `hbbr`). They're available on [Docker Hub](https://hub.docker.com/r/rustdesk/rustdesk-server/) and [GitHub Container Registry](https://github.com/rustdesk/rustdesk-server/pkgs/container/rustdesk-server) with these architectures:
|
||||
|
||||
* amd64
|
||||
* arm64v8
|
||||
* armv7
|
||||
|
||||
You could use `latest` tag or major version tag `1` with supported architectures:
|
||||
|
||||
| Version | image:tag |
|
||||
| ------------- | --------------------------------- |
|
||||
| latest | `rustdesk/rustdesk-server:latest` |
|
||||
| Major version | `rustdesk/rustdesk-server:1` |
|
||||
|
||||
|
||||
You can start these images directly with `docker run` with these commands:
|
||||
|
||||
```bash
|
||||
docker run --name hbbs --net=host -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbs -r <relay-server-ip[:port]>
|
||||
docker run --name hbbr --net=host -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbr
|
||||
```
|
||||
|
||||
or without `--net=host`, but P2P direct connection can not work.
|
||||
|
||||
For systems using SELinux, replacing `/root` by `/root:z` is required for the containers to run correctly. Alternatively, SELinux container separation can be disabled completely adding the option `--security-opt label=disable`.
|
||||
|
||||
```bash
|
||||
docker run --name hbbs -p 21115:21115 -p 21116:21116 -p 21116:21116/udp -p 21118:21118 -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbs -r <relay-server-ip[:port]>
|
||||
docker run --name hbbr -p 21117:21117 -p 21119:21119 -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbr
|
||||
```
|
||||
|
||||
The `relay-server-ip` parameter is the IP address (or dns name) of the server running these containers. The **optional** `port` parameter has to be used if you use a port different than **21117** for `hbbr`.
|
||||
|
||||
You can also use docker-compose, using this configuration as a template:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
networks:
|
||||
rustdesk-net:
|
||||
external: false
|
||||
|
||||
services:
|
||||
hbbs:
|
||||
container_name: hbbs
|
||||
ports:
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21118:21118
|
||||
image: rustdesk/rustdesk-server:latest
|
||||
command: hbbs -r rustdesk.example.com:21117
|
||||
volumes:
|
||||
- ./data:/root
|
||||
networks:
|
||||
- rustdesk-net
|
||||
depends_on:
|
||||
- hbbr
|
||||
restart: unless-stopped
|
||||
|
||||
hbbr:
|
||||
container_name: hbbr
|
||||
ports:
|
||||
- 21117:21117
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server:latest
|
||||
command: hbbr
|
||||
volumes:
|
||||
- ./data:/root
|
||||
networks:
|
||||
- rustdesk-net
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
Edit line 16 to point to your relay server (the one listening on port 21117). You can also edit the volume lines (line 18 and line 33) if you need.
|
||||
|
||||
(docker-compose credit goes to @lukebarone and @QuiGonLeong)
|
||||
|
||||
> [!NOTE]
|
||||
> The rustdesk/rustdesk-server:latest in China may be replaced with the latest version number on Docker Hub, such as `rustdesk-server:1.1.10-3`. Otherwise, the old version may be pulled due to image acceleration.
|
||||
|
||||
> [!NOTE]
|
||||
> If you are experiencing issues pulling from Docker Hub, try pulling from the [GitHub Container Registry](https://github.com/rustdesk/rustdesk-server/pkgs/container/rustdesk-server) instead.
|
||||
|
||||
## S6-overlay based images
|
||||
|
||||
These images are build against `busybox:stable` with the addition of the binaries (both `hbbs` and `hbbr`) and [S6-overlay](https://github.com/just-containers/s6-overlay). They're available on [Docker hub](https://hub.docker.com/r/rustdesk/rustdesk-server-s6/) and [GitHub Container Registry](https://github.com/rustdesk/rustdesk-server/pkgs/container/rustdesk-server) with these architectures:
|
||||
|
||||
* amd64
|
||||
* i386
|
||||
* arm64v8
|
||||
* armv7
|
||||
|
||||
You could use `latest` tag or major version tag `1` with supported architectures:
|
||||
|
||||
| Version | image:tag |
|
||||
| ------------- | ------------------------------------ |
|
||||
| latest | `rustdesk/rustdesk-server-s6:latest` |
|
||||
| Major version | `rustdesk/rustdesk-server-s6:1` |
|
||||
|
||||
The S6-overlay acts as a supervisor and keeps both process running, so with this image, there's no need to have two separate running containers.
|
||||
|
||||
You can start these images directly with `docker run` with this command:
|
||||
|
||||
```bash
|
||||
docker run --name rustdesk-server \
|
||||
--net=host \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-v "$PWD/data:/data" -d rustdesk/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
or without `--net=host`, but P2P direct connection cannot work.
|
||||
|
||||
```bash
|
||||
docker run --name rustdesk-server \
|
||||
-p 21115:21115 -p 21116:21116 -p 21116:21116/udp \
|
||||
-p 21117:21117 -p 21118:21118 -p 21119:21119 \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-v "$PWD/data:/data" -d rustdesk/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
Or you can use a docker-compose file:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
rustdesk-server:
|
||||
container_name: rustdesk-server
|
||||
ports:
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- "RELAY=rustdesk.example.com:21117"
|
||||
- "ENCRYPTED_ONLY=1"
|
||||
volumes:
|
||||
- ./data:/data
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
For this container image, you can use these environment variables, **in addition** to the ones specified in the following **ENV variables** section:
|
||||
|
||||
| variable | optional | description |
|
||||
| --- | --- | --- |
|
||||
| RELAY | no | the IP address/DNS name of the machine running this container |
|
||||
| ENCRYPTED_ONLY | yes | if set to **"1"** unencrypted connection will not be accepted |
|
||||
| KEY_PUB | yes | public part of the key pair |
|
||||
| KEY_PRIV | yes | private part of the key pair |
|
||||
|
||||
### Secret management in S6-overlay based images
|
||||
|
||||
You can obviously keep the key pair in a docker volume, but the best practices tells you to not write the keys on the filesystem; so we provide a couple of options.
|
||||
|
||||
On container startup, the presence of the keypair is checked (`/data/id_ed25519.pub` and `/data/id_ed25519`) and if one of these keys doesn't exist, it's recreated from ENV variables or docker secrets.
|
||||
Then the validity of the keypair is checked: if public and private keys doesn't match, the container will stop.
|
||||
If you provide no keys, `hbbs` will generate one for you, and it'll place it in the default location.
|
||||
|
||||
#### Use ENV to store the key pair
|
||||
|
||||
You can use docker environment variables to store the keys. Just follow this examples:
|
||||
|
||||
```bash
|
||||
docker run --name rustdesk-server \
|
||||
--net=host \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-e "DB_URL=/db/db_v2.sqlite3" \
|
||||
-e "KEY_PRIV=FR2j78IxfwJNR+HjLluQ2Nh7eEryEeIZCwiQDPVe+PaITKyShphHAsPLn7So0OqRs92nGvSRdFJnE2MSyrKTIQ==" \
|
||||
-e "KEY_PUB=iEyskoaYRwLDy5+0qNDqkbPdpxr0kXRSZxNjEsqykyE=" \
|
||||
-v "$PWD/db:/db" -d rustdesk/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
rustdesk-server:
|
||||
container_name: rustdesk-server
|
||||
ports:
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- "RELAY=rustdesk.example.com:21117"
|
||||
- "ENCRYPTED_ONLY=1"
|
||||
- "DB_URL=/db/db_v2.sqlite3"
|
||||
- "KEY_PRIV=FR2j78IxfwJNR+HjLluQ2Nh7eEryEeIZCwiQDPVe+PaITKyShphHAsPLn7So0OqRs92nGvSRdFJnE2MSyrKTIQ=="
|
||||
- "KEY_PUB=iEyskoaYRwLDy5+0qNDqkbPdpxr0kXRSZxNjEsqykyE="
|
||||
volumes:
|
||||
- ./db:/db
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
#### Use Docker secrets to store the key pair
|
||||
|
||||
You can alternatively use docker secrets to store the keys.
|
||||
This is useful if you're using **docker-compose** or **Docker Swarm**.
|
||||
Just follow this examples:
|
||||
|
||||
```bash
|
||||
cat secrets/id_ed25519.pub | docker secret create key_pub -
|
||||
cat secrets/id_ed25519 | docker secret create key_priv -
|
||||
docker service create --name rustdesk-server \
|
||||
--secret key_priv --secret key_pub \
|
||||
--net=host \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-e "DB_URL=/db/db_v2.sqlite3" \
|
||||
--mount "type=bind,source=$PWD/db,destination=/db" \
|
||||
rustdesk/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
rustdesk-server:
|
||||
container_name: rustdesk-server
|
||||
ports:
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- "RELAY=rustdesk.example.com:21117"
|
||||
- "ENCRYPTED_ONLY=1"
|
||||
- "DB_URL=/db/db_v2.sqlite3"
|
||||
volumes:
|
||||
- ./db:/db
|
||||
restart: unless-stopped
|
||||
secrets:
|
||||
- key_pub
|
||||
- key_priv
|
||||
|
||||
secrets:
|
||||
key_pub:
|
||||
file: secrets/id_ed25519.pub
|
||||
key_priv:
|
||||
file: secrets/id_ed25519
|
||||
```
|
||||
|
||||
## How to create a keypair
|
||||
|
||||
A keypair is needed for encryption; you can provide it, as explained before, but you need a way to create one.
|
||||
|
||||
You can use this command to generate a keypair:
|
||||
|
||||
```bash
|
||||
/usr/bin/rustdesk-utils genkeypair
|
||||
```
|
||||
|
||||
If you don't have (or don't want) the `rustdesk-utils` package installed on your system, you can invoke the same command with docker:
|
||||
|
||||
```bash
|
||||
docker run --rm --entrypoint /usr/bin/rustdesk-utils rustdesk/rustdesk-server-s6:latest genkeypair
|
||||
```
|
||||
|
||||
The output will be something like this:
|
||||
|
||||
```text
|
||||
Public Key: 8BLLhtzUBU/XKAH4mep3p+IX4DSApe7qbAwNH9nv4yA=
|
||||
Secret Key: egAVd44u33ZEUIDTtksGcHeVeAwywarEdHmf99KM5ajwEsuG3NQFT9coAfiZ6nen4hfgNICl7upsDA0f2e/jIA==
|
||||
```
|
||||
|
||||
## .deb packages
|
||||
|
||||
Separate .deb packages are available for each binary, you can find them in the [Releases](https://github.com/rustdesk/rustdesk-server/releases).
|
||||
These packages are meant for the following distributions:
|
||||
|
||||
- Ubuntu 24.04 LTS
|
||||
- Ubuntu 22.04 LTS
|
||||
- Ubuntu 20.04 LTS
|
||||
- Ubuntu 18.04 LTS
|
||||
- Debian 12 bookworm
|
||||
- Debian 11 bullseye
|
||||
- Debian 10 buster
|
||||
|
||||
## ENV variables
|
||||
|
||||
`hbbs` and `hbbr` can be configured using these ENV variables.
|
||||
You can specify the variables as usual or use an `.env` file.
|
||||
|
||||
| variable | binary | description |
|
||||
| --- | --- | --- |
|
||||
| ALWAYS_USE_RELAY | hbbs | if set to **"Y"** disallows direct peer connection |
|
||||
| DB_URL | hbbs | path for database file |
|
||||
| DOWNGRADE_START_CHECK | hbbr | delay (in seconds) before downgrade check |
|
||||
| DOWNGRADE_THRESHOLD | hbbr | threshold of downgrade check (bit/ms) |
|
||||
| KEY | hbbs/hbbr | if set force the use of a specific key, if set to **"_"** force the use of any key |
|
||||
| LIMIT_SPEED | hbbr | speed limit (in Mb/s) |
|
||||
| PORT | hbbs/hbbr | listening port (21116 for hbbs - 21117 for hbbr) |
|
||||
| RELAY | hbbs | IP address/DNS name of the machines running hbbr (separated by comma) |
|
||||
| RUST_LOG | all | set debug level (error\|warn\|info\|debug\|trace) |
|
||||
| SINGLE_BANDWIDTH | hbbr | max bandwidth for a single connection (in Mb/s) |
|
||||
| TOTAL_BANDWIDTH | hbbr | max total bandwidth (in Mb/s) |
|
||||
@@ -1,3 +1,66 @@
|
||||
|
||||
# About this repository
|
||||
|
||||
[](https://github.com/lejianwen/rustdesk-server/actions/workflows/build.yaml)
|
||||
|
||||
- Solves the issue of connection timeout when the client logs in with an `API` account
|
||||
- Added `API` support to the s6 image, `API` open-source repository: https://github.com/lejianwen/rustdesk-api
|
||||
- Whether login is required to connect, `MUST_LOGIN` defaults to `N`, set to `Y` to require login for connection
|
||||
- `RUSTDESK_API_JWT_KEY`, when set, validates the token's legitimacy through `JWT`
|
||||
- Support client websocket (client >= 1.4.1)
|
||||
|
||||
## docker
|
||||
|
||||
- s6 Image [lejianwen/rustdesk-server-s6](https://hub.docker.com/r/lejianwen/rustdesk-server-s6)
|
||||
|
||||
```yaml
|
||||
networks:
|
||||
rustdesk-net:
|
||||
external: false
|
||||
services:
|
||||
rustdesk:
|
||||
ports:
|
||||
- 21114:21114
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: lejianwen/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- RELAY=<relay_server[:port]>
|
||||
- ENCRYPTED_ONLY=1
|
||||
- MUST_LOGIN=N
|
||||
- TZ=Asia/Shanghai
|
||||
- RUSTDESK_API_RUSTDESK_ID_SERVER=<id_server[:21116]>
|
||||
- RUSTDESK_API_RUSTDESK_RELAY_SERVER=<relay_server[:21117]>
|
||||
- RUSTDESK_API_RUSTDESK_API_SERVER=http://<api_server[:21114]>
|
||||
- RUSTDESK_API_KEY_FILE=/data/id_ed25519.pub
|
||||
- RUSTDESK_API_JWT_KEY=xxxxxx # jwt key
|
||||
volumes:
|
||||
- /data/rustdesk/server:/data
|
||||
- /data/rustdesk/api:/app/data #
|
||||
networks:
|
||||
- rustdesk-net
|
||||
restart: unless-stopped
|
||||
|
||||
```
|
||||
|
||||
- Common Image [lejianwen/rustdesk-server](https://hub.docker.com/r/lejianwen/rustdesk-server)
|
||||
|
||||
|
||||
# API Screenshot
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
More See [RustDesk Api](https://github.com/lejianwen/rustdesk-api)
|
||||
|
||||
|
||||
|
||||
|
||||
<p align="center">
|
||||
<a href="#hoe-handmatig-opbouwen">Opbouwen</a> •
|
||||
<a href="#docker-bestanden-images">Docker</a> •
|
||||
|
||||
+86
-25
@@ -1,3 +1,63 @@
|
||||
# 关于此分支
|
||||
|
||||
[](https://github.com/lejianwen/rustdesk-server/actions/workflows/build.yaml)
|
||||
|
||||
- 解决当客户端登录了`Api`账号时链接超时的问题
|
||||
- s6镜像添加了`Api`支持,`Api`开源地址 https://github.com/lejianwen/rustdesk-api
|
||||
- 是否必须登录才能链接, `MUST_LOGIN` 默认为 `N`,设置为 `Y` 则必须登录才能链接
|
||||
- `RUSTDESK_API_JWT_KEY`,设置后会通过`JWT`校验token的合法性
|
||||
- Support client websocket (client >= 1.4.1)
|
||||
|
||||
## docker镜像地址
|
||||
|
||||
- s6 镜像 [lejianwen/rustdesk-server-s6](https://hub.docker.com/r/lejianwen/rustdesk-server-s6)
|
||||
|
||||
```yaml
|
||||
networks:
|
||||
rustdesk-net:
|
||||
external: false
|
||||
services:
|
||||
rustdesk:
|
||||
ports:
|
||||
- 21114:21114
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: lejianwen/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- RELAY=<relay_server[:port]>
|
||||
- ENCRYPTED_ONLY=1
|
||||
- MUST_LOGIN=N
|
||||
- TZ=Asia/Shanghai
|
||||
- RUSTDESK_API_RUSTDESK_ID_SERVER=<id_server[:21116]>
|
||||
- RUSTDESK_API_RUSTDESK_RELAY_SERVER=<relay_server[:21117]>
|
||||
- RUSTDESK_API_RUSTDESK_API_SERVER=http://<api_server[:21114]>
|
||||
- RUSTDESK_API_KEY_FILE=/data/id_ed25519.pub
|
||||
- RUSTDESK_API_JWT_KEY=xxxxxx # jwt key
|
||||
volumes:
|
||||
- /data/rustdesk/server:/data
|
||||
- /data/rustdesk/api:/app/data #将数据库挂载
|
||||
networks:
|
||||
- rustdesk-net
|
||||
restart: unless-stopped
|
||||
|
||||
```
|
||||
|
||||
- 普通镜像 [lejianwen/rustdesk-server](https://hub.docker.com/r/lejianwen/rustdesk-server)
|
||||
|
||||
# API功能截图
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
更多查看 [RustDesk Api](https://github.com/lejianwen/rustdesk-api)
|
||||
|
||||
|
||||
|
||||
<p align="center">
|
||||
<a href="#如何自行建置">自行建置</a> •
|
||||
<a href="#Docker-映像檔">Docker</a> •
|
||||
@@ -46,8 +106,8 @@ Docker 映像檔會在每次 GitHub 發布時自動生成並發布。我們有
|
||||
|
||||
這些映像檔是基於 `ubuntu-20.04` 建置的,僅添加了兩個主要的執行檔(`hbbr` 和 `hbbs`)。它們可在 [Docker Hub](https://hub.docker.com/r/rustdesk/rustdesk-server/) 上取得,帶有以下tags:
|
||||
|
||||
| 架構 | image:tag |
|
||||
| ------- | ----------------------------------------- |
|
||||
| 架構 | image:tag |
|
||||
|---------|-------------------------------------------|
|
||||
| amd64 | `rustdesk/rustdesk-server:latest` |
|
||||
| arm64v8 | `rustdesk/rustdesk-server:latest-arm64v8` |
|
||||
|
||||
@@ -116,10 +176,11 @@ services:
|
||||
|
||||
## 基於 S6-overlay 的映象檔
|
||||
|
||||
這些映象檔是針對 `busybox:stable` 建置的,並添加了執行檔(hbbr 和 hbbs)以及 [S6-overlay](https://github.com/just-containers/s6-overlay)。 它們在以及這些 tags 在 [Docker hub](https://hub.docker.com/r/rustdesk/rustdesk-server-s6/) 可用:
|
||||
這些映象檔是針對 `busybox:stable` 建置的,並添加了執行檔(hbbr 和 hbbs)以及 [S6-overlay](https://github.com/just-containers/s6-overlay)。 它們在以及這些 tags
|
||||
在 [Docker hub](https://hub.docker.com/r/rustdesk/rustdesk-server-s6/) 可用:
|
||||
|
||||
| 架構 | version | image:tag |
|
||||
| --------- | ------- | -------------------------------------------- |
|
||||
| 架構 | version | image:tag |
|
||||
|-----------|---------|----------------------------------------------|
|
||||
| multiarch | latest | `rustdesk/rustdesk-server-s6:latest` |
|
||||
| amd64 | latest | `rustdesk/rustdesk-server-s6:latest-amd64` |
|
||||
| i386 | latest | `rustdesk/rustdesk-server-s6:latest-i386` |
|
||||
@@ -187,14 +248,14 @@ services:
|
||||
|
||||
對於此容器映象檔,您可以使用這些環境變數,**除了**以下**環境變數**部分指定的那些。
|
||||
|
||||
| 環境變數 | 是否可選 | 敘述 |
|
||||
| -------------- | -------- | ------------------------------------------ |
|
||||
| RELAY | 否 | 運行此容器的機器的 IP 地址/ DNS 名稱 |
|
||||
| ENCRYPTED_ONLY | 是 | 如果設置為 **"1"**,將不接受未加密的連接。 |
|
||||
| KEY_PUB | 是 | 金鑰對中的公鑰(Public Key) |
|
||||
| KEY_PRIV | 是 | 金鑰對中的私鑰(Private Key) |
|
||||
| 環境變數 | 是否可選 | 敘述 |
|
||||
|----------------|------|---------------------------|
|
||||
| RELAY | 否 | 運行此容器的機器的 IP 地址/ DNS 名稱 |
|
||||
| ENCRYPTED_ONLY | 是 | 如果設置為 **"1"**,將不接受未加密的連接。 |
|
||||
| KEY_PUB | 是 | 金鑰對中的公鑰(Public Key) |
|
||||
| KEY_PRIV | 是 | 金鑰對中的私鑰(Private Key) |
|
||||
|
||||
### 在基於 S6-overlay 的 Secret 管理
|
||||
### 在基於 S6-overlay 的 Secret 管理
|
||||
|
||||
您可以將金鑰對保存在 Docker volume 中,但最佳實踐建議不要將金鑰寫入文件系統;因此,我們提供了一些選項。
|
||||
|
||||
@@ -332,16 +393,16 @@ Secret Key: egAVd44u33ZEUIDTtksGcHeVeAwywarEdHmf99KM5ajwEsuG3NQFT9coAfiZ6nen4hf
|
||||
可以使用這些 ENV 參數來配置 hbbs 和 hbbr。
|
||||
您可以像往常一樣指定參數,或者使用 .env 文件。
|
||||
|
||||
| 參數 | 執行檔 | 敘述 |
|
||||
| --------------------- | --------- | -------------------------------------------------------------------- |
|
||||
| ALWAYS_USE_RELAY | hbbs | 如果設為 **"Y"**,禁止直接點對點連接 |
|
||||
| DB_URL | hbbs | 資料庫的路徑 |
|
||||
| DOWNGRADE_START_CHECK | hbbr | 降級檢查之前的延遲時間(以秒為單位) |
|
||||
| DOWNGRADE_THRESHOLD | hbbr | 降級檢查的閾值(bit/ms) |
|
||||
| KEY | hbbs/hbbr | 如果設置了,將強制使用特定金鑰,如果設為 **"_"**,則強制使用任何金鑰 |
|
||||
| LIMIT_SPEED | hbbr | 速度限制(以Mb/s為單位) |
|
||||
| PORT | hbbs/hbbr | 監聽端口(hbbs為21116,hbbr為21117) |
|
||||
| RELAY_SERVERS | hbbs | 運行hbbr的機器的IP地址/DNS名稱(用逗號分隔) |
|
||||
| RUST_LOG | all | 設定 debug level (error\|warn\|info\|debug\|trace) |
|
||||
| SINGLE_BANDWIDTH | hbbr | 單個連接的最大頻寬(以Mb/s為單位) |
|
||||
| TOTAL_BANDWIDTH | hbbr | 最大總頻寬(以Mb/s為單位) |
|
||||
| 參數 | 執行檔 | 敘述 |
|
||||
|-----------------------|-----------|--------------------------------------------------|
|
||||
| ALWAYS_USE_RELAY | hbbs | 如果設為 **"Y"**,禁止直接點對點連接 |
|
||||
| DB_URL | hbbs | 資料庫的路徑 |
|
||||
| DOWNGRADE_START_CHECK | hbbr | 降級檢查之前的延遲時間(以秒為單位) |
|
||||
| DOWNGRADE_THRESHOLD | hbbr | 降級檢查的閾值(bit/ms) |
|
||||
| KEY | hbbs/hbbr | 如果設置了,將強制使用特定金鑰,如果設為 **"_"**,則強制使用任何金鑰 |
|
||||
| LIMIT_SPEED | hbbr | 速度限制(以Mb/s為單位) |
|
||||
| PORT | hbbs/hbbr | 監聽端口(hbbs為21116,hbbr為21117) |
|
||||
| RELAY_SERVERS | hbbs | 運行hbbr的機器的IP地址/DNS名稱(用逗號分隔) |
|
||||
| RUST_LOG | all | 設定 debug level (error\|warn\|info\|debug\|trace) |
|
||||
| SINGLE_BANDWIDTH | hbbr | 單個連接的最大頻寬(以Mb/s為單位) |
|
||||
| TOTAL_BANDWIDTH | hbbr | 最大總頻寬(以Mb/s為單位) |
|
||||
-348
@@ -1,348 +0,0 @@
|
||||
<p align="center">
|
||||
<a href="#如何自行构建">自行构建</a> •
|
||||
<a href="#Docker-镜像">Docker</a> •
|
||||
<a href="#基于-S6-overlay-的镜像">S6-overlay</a> •
|
||||
<a href="#如何创建密钥">密钥</a> •
|
||||
<a href="#deb-套件">Debian</a> •
|
||||
<a href="#ENV-环境参数">环境参数</a><br>
|
||||
[<a href="README.md">English</a>] | [<a href="README-DE.md">Deutsch</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-TW.md">繁体中文</a>]<br>
|
||||
</p>
|
||||
|
||||
# RustDesk Server Program
|
||||
|
||||
[](https://github.com/rustdesk/rustdesk-server/actions/workflows/build.yaml)
|
||||
|
||||
[**下载**](https://github.com/rustdesk/rustdesk-server/releases)
|
||||
|
||||
[**说明文件**](https://rustdesk.com/docs/zh-cn/self-host/)
|
||||
|
||||
[**FAQ**](https://github.com/rustdesk/rustdesk/wiki/FAQ)
|
||||
|
||||
自行搭建属于你的RustDesk服务器,所有的一切都是免费且开源的
|
||||
|
||||
## 如何自行构建
|
||||
|
||||
```bash
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
执行后会在target/release目录下生成三个对应平台的可执行程序
|
||||
|
||||
- hbbs - RustDesk ID/会和服务器
|
||||
- hbbr - RustDesk 中继服务器
|
||||
- rustdesk-utils - RustDesk 命令行工具
|
||||
|
||||
您可以在 [releases](https://github.com/rustdesk/rustdesk-server/releases) 页面中找到最新的服务端软件。
|
||||
|
||||
如果您需要额外的功能支持,[RustDesk 专业版服务器](https://rustdesk.com/pricing.html) 获取更适合您。
|
||||
|
||||
如果您想开发自己的服务器,[rustdesk-server-demo](https://github.com/rustdesk/rustdesk-server-demo) 应该会比直接使用这个仓库更简单快捷。
|
||||
|
||||
## Docker 镜像
|
||||
|
||||
Docker镜像会在每次 GitHub 发布新的release版本时自动构建。我们提供两种类型的镜像。
|
||||
|
||||
### Classic 传统镜像
|
||||
|
||||
这个类型的镜像是基于 `ubuntu-20.04` 进行构建,镜像仅包含两个主要的可执行程序(`hbbr` 和 `hbbs`)。它们可以通过以下tag在 [Docker Hub](https://hub.docker.com/r/rustdesk/rustdesk-server/) 上获得:
|
||||
|
||||
| 架构 | image:tag |
|
||||
|---------| ----------------------------------------- |
|
||||
| amd64 | `rustdesk/rustdesk-server:latest` |
|
||||
| arm64v8 | `rustdesk/rustdesk-server:latest-arm64v8` |
|
||||
|
||||
您可以使用以下命令,直接通过 ``docker run`` 來启动这些镜像:
|
||||
|
||||
```bash
|
||||
docker run --name hbbs --net=host -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbs -r <relay-server-ip[:port]>
|
||||
docker run --name hbbr --net=host -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbr
|
||||
```
|
||||
|
||||
或不使用 `--net=host` 参数启动, 但这样 P2P 直连功能将无法工作。
|
||||
|
||||
对于使用了 SELinux 的系统,您需要将 ``/root`` 替换为 ``/root:z``,以保证容器的正常运行。或者,也可以通过添加参数 ``--security-opt label=disable`` 来完全禁用 SELinux 容器隔离。
|
||||
|
||||
```bash
|
||||
docker run --name hbbs -p 21115:21115 -p 21116:21116 -p 21116:21116/udp -p 21118:21118 -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbs -r <relay-server-ip[:port]>
|
||||
docker run --name hbbr -p 21117:21117 -p 21119:21119 -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbr
|
||||
```
|
||||
|
||||
`relay-server-ip` 参数是运行这些容器的服务器的 IP 地址(或 DNS 名称)。如果你不想使用 **21117** 作为 `hbbr` 的服务端口,可使用可选参数 `port` 进行指定。
|
||||
|
||||
您也可以使用 docker-compose 进行构建,以下为配置示例:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
networks:
|
||||
rustdesk-net:
|
||||
external: false
|
||||
|
||||
services:
|
||||
hbbs:
|
||||
container_name: hbbs
|
||||
ports:
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21118:21118
|
||||
image: rustdesk/rustdesk-server:latest
|
||||
command: hbbs -r rustdesk.example.com:21117
|
||||
volumes:
|
||||
- ./data:/root
|
||||
networks:
|
||||
- rustdesk-net
|
||||
depends_on:
|
||||
- hbbr
|
||||
restart: unless-stopped
|
||||
|
||||
hbbr:
|
||||
container_name: hbbr
|
||||
ports:
|
||||
- 21117:21117
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server:latest
|
||||
command: hbbr
|
||||
volumes:
|
||||
- ./data:/root
|
||||
networks:
|
||||
- rustdesk-net
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
编辑第16行来指定你的中继服务器 (默认端口监听在 21117 的那一个)。 如果需要的话,您也可以编辑 volume 信息 (第 18 和 33 行)。
|
||||
|
||||
(感谢 @lukebarone 和 @QuiGonLeong 协助提供的 docker-compose 配置示例)
|
||||
|
||||
## 基于 S6-overlay 的镜像
|
||||
|
||||
> 这些镜像是针对 `busybox:stable` 构建的,并添加了可执行程序(hbbr 和 hbbs)以及 [S6-overlay](https://github.com/just-containers/s6-overlay)。 它们可以使用以下tag在 [Docker hub](https://hub.docker.com/r/rustdesk/rustdesk-server-s6/) 上获取:
|
||||
|
||||
|
||||
| 架構 | version | image:tag |
|
||||
| --------- | ------- | -------------------------------------------- |
|
||||
| multiarch | latest | `rustdesk/rustdesk-server-s6:latest` |
|
||||
| amd64 | latest | `rustdesk/rustdesk-server-s6:latest-amd64` |
|
||||
| i386 | latest | `rustdesk/rustdesk-server-s6:latest-i386` |
|
||||
| arm64v8 | latest | `rustdesk/rustdesk-server-s6:latest-arm64v8` |
|
||||
| armv7 | latest | `rustdesk/rustdesk-server-s6:latest-armv7` |
|
||||
| multiarch | 2 | `rustdesk/rustdesk-server-s6:2` |
|
||||
| amd64 | 2 | `rustdesk/rustdesk-server-s6:2-amd64` |
|
||||
| i386 | 2 | `rustdesk/rustdesk-server-s6:2-i386` |
|
||||
| arm64v8 | 2 | `rustdesk/rustdesk-server-s6:2-arm64v8` |
|
||||
| armv7 | 2 | `rustdesk/rustdesk-server-s6:2-armv7` |
|
||||
| multiarch | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0` |
|
||||
| amd64 | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0-amd64` |
|
||||
| i386 | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0-i386` |
|
||||
| arm64v8 | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0-arm64v8` |
|
||||
| armv7 | 2.0.0 | `rustdesk/rustdesk-server-s6:2.0.0-armv7` |
|
||||
|
||||
强烈建议您使用`major version` 或 `latest` tag 的 `multiarch` 架构的镜像。
|
||||
|
||||
S6-overlay 在此处作为监控程序,用以保证两个进程的运行,因此使用此镜像,您无需运行两个容器。
|
||||
|
||||
您可以使用 `docker run` 命令直接启动镜像,如下:
|
||||
|
||||
```bash
|
||||
docker run --name rustdesk-server \
|
||||
--net=host \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-v "$PWD/data:/data" -d rustdesk/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
或刪去 `--net=host` 参数, 但 P2P 直连功能将无法工作。
|
||||
|
||||
```bash
|
||||
docker run --name rustdesk-server \
|
||||
-p 21115:21115 -p 21116:21116 -p 21116:21116/udp \
|
||||
-p 21117:21117 -p 21118:21118 -p 21119:21119 \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-v "$PWD/data:/data" -d rustdesk/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
或着您也可以使用 docker-compose 文件:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
rustdesk-server:
|
||||
container_name: rustdesk-server
|
||||
ports:
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- "RELAY=rustdesk.example.com:21117"
|
||||
- "ENCRYPTED_ONLY=1"
|
||||
volumes:
|
||||
- ./data:/data
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
对于此容器镜像,除了在下面的环境变量部分指定的变量之外,您还可以使用以下`环境变量`
|
||||
|
||||
| 环境变量 | 是否可选 | 描述 |
|
||||
|----------------|------|--------------------------|
|
||||
| RELAY | 否 | 运行此容器的宿主机的 IP 地址/ DNS 名称 |
|
||||
| ENCRYPTED_ONLY | 是 | 如果设置为 **"1"**,将不接受未加密的连接。 |
|
||||
| KEY_PUB | 是 | 密钥对中的公钥(Public Key) |
|
||||
| KEY_PRIV | 是 | 密钥对中的私钥(Private Key) |
|
||||
|
||||
### 基于 S6-overlay 镜像的密钥管理
|
||||
|
||||
您可以将密钥对保存在 Docker volume 中,但我们建议不要将密钥写入文件系統中;因此,我们提供了一些方案。
|
||||
|
||||
在容器启动时,会检查密钥对是否存在(`/data/id_ed25519.pub` 和 `/data/id_ed25519`),如果其中一個密钥不存在,则会从环境变量或 Docker Secret 中重新生成它。
|
||||
然后检查密钥对的可用性:如果公钥和私钥不匹配,容器将停止运行。
|
||||
如果您未提供密钥,`hbbs` 将会在默认位置生成一个。
|
||||
|
||||
#### 使用 ENV 存储密钥对
|
||||
|
||||
您可以使用 Docker 环境变量來存储密钥。如下:
|
||||
|
||||
```bash
|
||||
docker run --name rustdesk-server \
|
||||
--net=host \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-e "DB_URL=/db/db_v2.sqlite3" \
|
||||
-e "KEY_PRIV=FR2j78IxfwJNR+HjLluQ2Nh7eEryEeIZCwiQDPVe+PaITKyShphHAsPLn7So0OqRs92nGvSRdFJnE2MSyrKTIQ==" \
|
||||
-e "KEY_PUB=iEyskoaYRwLDy5+0qNDqkbPdpxr0kXRSZxNjEsqykyE=" \
|
||||
-v "$PWD/db:/db" -d rustdesk/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
rustdesk-server:
|
||||
container_name: rustdesk-server
|
||||
ports:
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- "RELAY=rustdesk.example.com:21117"
|
||||
- "ENCRYPTED_ONLY=1"
|
||||
- "DB_URL=/db/db_v2.sqlite3"
|
||||
- "KEY_PRIV=FR2j78IxfwJNR+HjLluQ2Nh7eEryEeIZCwiQDPVe+PaITKyShphHAsPLn7So0OqRs92nGvSRdFJnE2MSyrKTIQ=="
|
||||
- "KEY_PUB=iEyskoaYRwLDy5+0qNDqkbPdpxr0kXRSZxNjEsqykyE="
|
||||
volumes:
|
||||
- ./db:/db
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
#### 使用 Docker Secret 來保存密钥对
|
||||
|
||||
您还可以使用 Docker Secret 來保存密钥。
|
||||
如果您使用 **docker-compose** 或 **docker swarm**,推荐您使用。
|
||||
只需按照以下示例操作:
|
||||
|
||||
```bash
|
||||
cat secrets/id_ed25519.pub | docker secret create key_pub -
|
||||
cat secrets/id_ed25519 | docker secret create key_priv -
|
||||
docker service create --name rustdesk-server \
|
||||
--secret key_priv --secret key_pub \
|
||||
--net=host \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-e "DB_URL=/db/db_v2.sqlite3" \
|
||||
--mount "type=bind,source=$PWD/db,destination=/db" \
|
||||
rustdesk/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
rustdesk-server:
|
||||
container_name: rustdesk-server
|
||||
ports:
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- "RELAY=rustdesk.example.com:21117"
|
||||
- "ENCRYPTED_ONLY=1"
|
||||
- "DB_URL=/db/db_v2.sqlite3"
|
||||
volumes:
|
||||
- ./db:/db
|
||||
restart: unless-stopped
|
||||
secrets:
|
||||
- key_pub
|
||||
- key_priv
|
||||
|
||||
secrets:
|
||||
key_pub:
|
||||
file: secrets/id_ed25519.pub
|
||||
key_priv:
|
||||
file: secrets/id_ed25519
|
||||
```
|
||||
|
||||
## 如何生成密钥对
|
||||
|
||||
加密需要一对密钥;您可以按照前面所述提供它,但需要一个工具去生成密钥对。
|
||||
|
||||
您可以使用以下命令生成一对密钥:
|
||||
|
||||
```bash
|
||||
/usr/bin/rustdesk-utils genkeypair
|
||||
```
|
||||
|
||||
如果您沒有(或不想)在系统上安装 `rustdesk-utils` 套件,您可以使用 Docker 执行相同的命令:
|
||||
|
||||
```bash
|
||||
docker run --rm --entrypoint /usr/bin/rustdesk-utils rustdesk/rustdesk-server-s6:latest genkeypair
|
||||
```
|
||||
|
||||
运行后的输出内容如下:
|
||||
|
||||
```text
|
||||
Public Key: 8BLLhtzUBU/XKAH4mep3p+IX4DSApe7qbAwNH9nv4yA=
|
||||
Secret Key: egAVd44u33ZEUIDTtksGcHeVeAwywarEdHmf99KM5ajwEsuG3NQFT9coAfiZ6nen4hfgNICl7upsDA0f2e/jIA==
|
||||
```
|
||||
|
||||
## .deb 套件
|
||||
|
||||
每个可执行文件都有单独的 .deb 套件可供使用,您可以在 [releases](https://github.com/rustdesk/rustdesk-server/releases) 页面中找到它們。
|
||||
這些套件适用于以下发行版:
|
||||
|
||||
- Ubuntu 22.04 LTS
|
||||
- Ubuntu 20.04 LTS
|
||||
- Ubuntu 18.04 LTS
|
||||
- Debian 11 bullseye
|
||||
- Debian 10 buster
|
||||
|
||||
## ENV 环境变量
|
||||
|
||||
可以使用这些`环境变量`参数來配置 hbbs 和 hbbr。
|
||||
您可以像往常一样指定参数,或者使用 .env 文件。
|
||||
|
||||
| 参数 | 可执行文件 | 描述 |
|
||||
|-----------------------|---------------|--------------------------------------------------|
|
||||
| ALWAYS_USE_RELAY | hbbs | 如果设定为 **"Y"**,将关闭直接点对点连接功能 |
|
||||
| DB_URL | hbbs | 数据库配置 |
|
||||
| DOWNGRADE_START_CHECK | hbbr | 降级检查之前的延迟是啊尽(以秒为单位) |
|
||||
| DOWNGRADE_THRESHOLD | hbbr | 降级检查的阈值(bit/ms) |
|
||||
| KEY | hbbs/hbbr | 如果设置了此参数,将强制使用指定密钥对,如果设为 **"_"**,则强制使用任意密钥 |
|
||||
| LIMIT_SPEED | hbbr | 速度限制(以Mb/s为单位) |
|
||||
| PORT | hbbs/hbbr | 监听端口(hbbs为21116,hbbr为21117) |
|
||||
| RELAY_SERVERS | hbbs | 运行hbbr的机器的IP地址/DNS名称(用逗号分隔) |
|
||||
| RUST_LOG | all | 设置 debug level (error\|warn\|info\|debug\|trace) |
|
||||
| SINGLE_BANDWIDTH | hbbr | 单个连接的最大带宽(以Mb/s为单位) |
|
||||
| TOTAL_BANDWIDTH | hbbr | 最大总带宽(以Mb/s为单位) |
|
||||
@@ -1,82 +1,138 @@
|
||||
|
||||
# 关于此分支
|
||||
|
||||
|
||||
|
||||
[](https://github.com/lejianwen/rustdesk-server/actions/workflows/build.yaml)
|
||||
|
||||
- 解决当客户端登录了`API`账号时链接超时的问题
|
||||
- s6镜像添加了`API`支持,`API`开源地址 https://github.com/lejianwen/rustdesk-api
|
||||
- 是否必须登录才能链接, `MUST_LOGIN` 默认为 `N`,设置为 `Y` 则必须登录才能链接
|
||||
- `RUSTDESK_API_JWT_KEY`,设置后会通过`JWT`校验token的合法性
|
||||
- 支持client websocket (client >= 1.4.1)
|
||||
|
||||
## docker镜像地址
|
||||
|
||||
- s6 镜像 [lejianwen/rustdesk-server-s6](https://hub.docker.com/r/lejianwen/rustdesk-server-s6)
|
||||
|
||||
```yaml
|
||||
networks:
|
||||
rustdesk-net:
|
||||
external: false
|
||||
services:
|
||||
rustdesk:
|
||||
ports:
|
||||
- 21114:21114
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: lejianwen/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- RELAY=<relay_server[:port]>
|
||||
- ENCRYPTED_ONLY=1
|
||||
- MUST_LOGIN=N
|
||||
- TZ=Asia/Shanghai
|
||||
- RUSTDESK_API_RUSTDESK_ID_SERVER=<id_server[:21116]>
|
||||
- RUSTDESK_API_RUSTDESK_RELAY_SERVER=<relay_server[:21117]>
|
||||
- RUSTDESK_API_RUSTDESK_API_SERVER=http://<api_server[:21114]>
|
||||
- RUSTDESK_API_KEY_FILE=/data/id_ed25519.pub
|
||||
- RUSTDESK_API_JWT_KEY=xxxxxx # jwt key
|
||||
volumes:
|
||||
- /data/rustdesk/server:/data
|
||||
- /data/rustdesk/api:/app/data #将数据库挂载
|
||||
networks:
|
||||
- rustdesk-net
|
||||
restart: unless-stopped
|
||||
|
||||
```
|
||||
|
||||
- 普通镜像 [lejianwen/rustdesk-server](https://hub.docker.com/r/lejianwen/rustdesk-server)
|
||||
|
||||
|
||||
# API功能截图
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
更多查看 [RustDesk Api](https://github.com/lejianwen/rustdesk-api)
|
||||
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
<a href="#how-to-build-manually">Manually</a> •
|
||||
<a href="#docker-images">Docker</a> •
|
||||
<a href="#s6-overlay-based-images">S6-overlay</a> •
|
||||
<a href="#how-to-create-a-keypair">Keypair</a> •
|
||||
<a href="#deb-packages">Debian</a> •
|
||||
<a href="#env-variables">Variables</a><br>
|
||||
[<a href="README-DE.md">Deutsch</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-TW.md">繁體中文</a>] | [<a href="README-ZH.md">简体中文</a>]<br>
|
||||
<a href="#如何自行构建">自行构建</a> •
|
||||
<a href="#Docker-镜像">Docker</a> •
|
||||
<a href="#基于-S6-overlay-的镜像">S6-overlay</a> •
|
||||
<a href="#如何创建密钥">密钥</a> •
|
||||
<a href="#deb-套件">Debian</a> •
|
||||
<a href="#ENV-环境参数">环境参数</a><br>
|
||||
[<a href="README-EN.md">English</a>] | [<a href="README-DE.md">Deutsch</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-TW.md">繁体中文</a>]<br>
|
||||
</p>
|
||||
|
||||
# RustDesk Server Program
|
||||
|
||||
[](https://github.com/rustdesk/rustdesk-server/actions/workflows/build.yaml)
|
||||
|
||||
[**Download**](https://github.com/rustdesk/rustdesk-server/releases)
|
||||
|
||||
[**Manual**](https://rustdesk.com/docs/en/self-host/)
|
||||
[**下载**](https://github.com/lejianwen/rustdesk-server/releases)
|
||||
|
||||
[**FAQ**](https://github.com/rustdesk/rustdesk/wiki/FAQ)
|
||||
[**说明文件**](https://rustdesk.com/docs/zh-cn/self-host/)
|
||||
|
||||
Self-host your own RustDesk server, it is free and open source.
|
||||
自行搭建属于你的RustDesk服务器,所有的一切都是免费且开源的
|
||||
|
||||
## How to build manually
|
||||
## 如何自行构建
|
||||
|
||||
```bash
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
Three executables will be generated in target/release.
|
||||
执行后会在target/release目录下生成三个对应平台的可执行程序
|
||||
|
||||
- hbbs - RustDesk ID/Rendezvous server
|
||||
- hbbr - RustDesk relay server
|
||||
- rustdesk-utils - RustDesk CLI utilities
|
||||
- hbbs - RustDesk ID/会和服务器
|
||||
- hbbr - RustDesk 中继服务器
|
||||
- rustdesk-utils - RustDesk 命令行工具
|
||||
|
||||
You can find updated binaries on the [Releases](https://github.com/rustdesk/rustdesk-server/releases) page.
|
||||
您可以在 [releases](https://github.com/lejianwen/rustdesk-server/releases) 页面中找到最新的服务端软件。
|
||||
|
||||
If you want extra features, [RustDesk Server Pro](https://rustdesk.com/pricing.html) might suit you better.
|
||||
如果您需要额外的功能支持,[RustDesk 专业版服务器](https://rustdesk.com/pricing.html) 获取更适合您。
|
||||
|
||||
If you want to develop your own server, [rustdesk-server-demo](https://github.com/rustdesk/rustdesk-server-demo) might be a better and simpler start for you than this repo.
|
||||
如果您想开发自己的服务器,[rustdesk-server-demo](https://github.com/rustdesk/rustdesk-server-demo) 应该会比直接使用这个仓库更简单快捷。
|
||||
|
||||
## Docker images
|
||||
## Docker 镜像
|
||||
|
||||
Docker images are automatically generated and published to [Docker Hub](https://hub.docker.com/r/rustdesk) and [GitHub Container Registry](https://github.com/rustdesk?tab=packages&repo_name=rustdesk-server) on every GitHub release. We have 2 kind of images.
|
||||
Docker镜像会在每次 GitHub 发布新的release版本时自动构建。我们提供两种类型的镜像。
|
||||
|
||||
### Classic image
|
||||
### Classic 传统镜像
|
||||
|
||||
These images are built from scratch with two main binaries (`hbbs` and `hbbr`). They're available on [Docker Hub](https://hub.docker.com/r/rustdesk/rustdesk-server/) and [GitHub Container Registry](https://github.com/rustdesk/rustdesk-server/pkgs/container/rustdesk-server) with these architectures:
|
||||
这个类型的镜像是基于 `ubuntu-20.04` 进行构建,镜像仅包含两个主要的可执行程序(`hbbr` 和 `hbbs`)。它们可以通过以下tag在 [Docker Hub](https://hub.docker.com/r/lejianwen/rustdesk-server/) 上获得:
|
||||
|
||||
* amd64
|
||||
* arm64v8
|
||||
* armv7
|
||||
| 架构 | image:tag |
|
||||
|---------| ----------------------------------------- |
|
||||
| amd64 | `lejianwen/rustdesk-server:latest` |
|
||||
| arm64v8 | `lejianwen/rustdesk-server:latest-arm64v8` |
|
||||
|
||||
You could use `latest` tag or major version tag `1` with supported architectures:
|
||||
|
||||
| Version | image:tag |
|
||||
| ------------- | --------------------------------- |
|
||||
| latest | `rustdesk/rustdesk-server:latest` |
|
||||
| Major version | `rustdesk/rustdesk-server:1` |
|
||||
|
||||
|
||||
You can start these images directly with `docker run` with these commands:
|
||||
您可以使用以下命令,直接通过 ``docker run`` 來启动这些镜像:
|
||||
|
||||
```bash
|
||||
docker run --name hbbs --net=host -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbs -r <relay-server-ip[:port]>
|
||||
docker run --name hbbr --net=host -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbr
|
||||
docker run --name hbbs --net=host -v "$PWD/data:/root" -d lejianwen/rustdesk-server:latest hbbs -r <relay-server-ip[:port]>
|
||||
docker run --name hbbr --net=host -v "$PWD/data:/root" -d lejianwen/rustdesk-server:latest hbbr
|
||||
```
|
||||
|
||||
or without `--net=host`, but P2P direct connection can not work.
|
||||
或不使用 `--net=host` 参数启动, 但这样 P2P 直连功能将无法工作。
|
||||
|
||||
For systems using SELinux, replacing `/root` by `/root:z` is required for the containers to run correctly. Alternatively, SELinux container separation can be disabled completely adding the option `--security-opt label=disable`.
|
||||
对于使用了 SELinux 的系统,您需要将 ``/root`` 替换为 ``/root:z``,以保证容器的正常运行。或者,也可以通过添加参数 ``--security-opt label=disable`` 来完全禁用 SELinux 容器隔离。
|
||||
|
||||
```bash
|
||||
docker run --name hbbs -p 21115:21115 -p 21116:21116 -p 21116:21116/udp -p 21118:21118 -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbs -r <relay-server-ip[:port]>
|
||||
docker run --name hbbr -p 21117:21117 -p 21119:21119 -v "$PWD/data:/root" -d rustdesk/rustdesk-server:latest hbbr
|
||||
docker run --name hbbs -p 21115:21115 -p 21116:21116 -p 21116:21116/udp -p 21118:21118 -v "$PWD/data:/root" -d lejianwen/rustdesk-server:latest hbbs -r <relay-server-ip[:port]>
|
||||
docker run --name hbbr -p 21117:21117 -p 21119:21119 -v "$PWD/data:/root" -d lejianwen/rustdesk-server:latest hbbr
|
||||
```
|
||||
|
||||
The `relay-server-ip` parameter is the IP address (or dns name) of the server running these containers. The **optional** `port` parameter has to be used if you use a port different than **21117** for `hbbr`.
|
||||
`relay-server-ip` 参数是运行这些容器的服务器的 IP 地址(或 DNS 名称)。如果你不想使用 **21117** 作为 `hbbr` 的服务端口,可使用可选参数 `port` 进行指定。
|
||||
|
||||
You can also use docker-compose, using this configuration as a template:
|
||||
您也可以使用 docker-compose 进行构建,以下为配置示例:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
@@ -93,7 +149,7 @@ services:
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21118:21118
|
||||
image: rustdesk/rustdesk-server:latest
|
||||
image: lejianwen/rustdesk-server:latest
|
||||
command: hbbs -r rustdesk.example.com:21117
|
||||
volumes:
|
||||
- ./data:/root
|
||||
@@ -108,7 +164,7 @@ services:
|
||||
ports:
|
||||
- 21117:21117
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server:latest
|
||||
image: lejianwen/rustdesk-server:latest
|
||||
command: hbbr
|
||||
volumes:
|
||||
- ./data:/root
|
||||
@@ -117,45 +173,48 @@ services:
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
Edit line 16 to point to your relay server (the one listening on port 21117). You can also edit the volume lines (line 18 and line 33) if you need.
|
||||
编辑第16行来指定你的中继服务器 (默认端口监听在 21117 的那一个)。 如果需要的话,您也可以编辑 volume 信息 (第 18 和 33 行)。
|
||||
|
||||
(docker-compose credit goes to @lukebarone and @QuiGonLeong)
|
||||
(感谢 @lukebarone 和 @QuiGonLeong 协助提供的 docker-compose 配置示例)
|
||||
|
||||
> [!NOTE]
|
||||
> The rustdesk/rustdesk-server:latest in China may be replaced with the latest version number on Docker Hub, such as `rustdesk-server:1.1.10-3`. Otherwise, the old version may be pulled due to image acceleration.
|
||||
## 基于 S6-overlay 的镜像
|
||||
|
||||
> [!NOTE]
|
||||
> If you are experiencing issues pulling from Docker Hub, try pulling from the [GitHub Container Registry](https://github.com/rustdesk/rustdesk-server/pkgs/container/rustdesk-server) instead.
|
||||
> 这些镜像是针对 `busybox:stable` 构建的,并添加了可执行程序(hbbr 和 hbbs)以及 [S6-overlay](https://github.com/just-containers/s6-overlay)。 它们可以使用以下tag在 [Docker hub](https://hub.docker.com/r/lejianwen/rustdesk-server-s6/) 上获取:
|
||||
|
||||
## S6-overlay based images
|
||||
|
||||
These images are build against `busybox:stable` with the addition of the binaries (both `hbbs` and `hbbr`) and [S6-overlay](https://github.com/just-containers/s6-overlay). They're available on [Docker hub](https://hub.docker.com/r/rustdesk/rustdesk-server-s6/) and [GitHub Container Registry](https://github.com/rustdesk/rustdesk-server/pkgs/container/rustdesk-server) with these architectures:
|
||||
| 架構 | version | image:tag |
|
||||
| --------- | ------- | -------------------------------------------- |
|
||||
| multiarch | latest | `lejianwen/rustdesk-server-s6:latest` |
|
||||
| amd64 | latest | `lejianwen/rustdesk-server-s6:latest-amd64` |
|
||||
| i386 | latest | `lejianwen/rustdesk-server-s6:latest-i386` |
|
||||
| arm64v8 | latest | `lejianwen/rustdesk-server-s6:latest-arm64v8` |
|
||||
| armv7 | latest | `lejianwen/rustdesk-server-s6:latest-armv7` |
|
||||
| multiarch | 2 | `lejianwen/rustdesk-server-s6:2` |
|
||||
| amd64 | 2 | `lejianwen/rustdesk-server-s6:2-amd64` |
|
||||
| i386 | 2 | `lejianwen/rustdesk-server-s6:2-i386` |
|
||||
| arm64v8 | 2 | `lejianwen/rustdesk-server-s6:2-arm64v8` |
|
||||
| armv7 | 2 | `lejianwen/rustdesk-server-s6:2-armv7` |
|
||||
| multiarch | 2.0.0 | `lejianwen/rustdesk-server-s6:2.0.0` |
|
||||
| amd64 | 2.0.0 | `lejianwen/rustdesk-server-s6:2.0.0-amd64` |
|
||||
| i386 | 2.0.0 | `lejianwen/rustdesk-server-s6:2.0.0-i386` |
|
||||
| arm64v8 | 2.0.0 | `lejianwen/rustdesk-server-s6:2.0.0-arm64v8` |
|
||||
| armv7 | 2.0.0 | `lejianwen/rustdesk-server-s6:2.0.0-armv7` |
|
||||
|
||||
* amd64
|
||||
* i386
|
||||
* arm64v8
|
||||
* armv7
|
||||
强烈建议您使用`major version` 或 `latest` tag 的 `multiarch` 架构的镜像。
|
||||
|
||||
You could use `latest` tag or major version tag `1` with supported architectures:
|
||||
S6-overlay 在此处作为监控程序,用以保证两个进程的运行,因此使用此镜像,您无需运行两个容器。
|
||||
|
||||
| Version | image:tag |
|
||||
| ------------- | ------------------------------------ |
|
||||
| latest | `rustdesk/rustdesk-server-s6:latest` |
|
||||
| Major version | `rustdesk/rustdesk-server-s6:1` |
|
||||
|
||||
The S6-overlay acts as a supervisor and keeps both process running, so with this image, there's no need to have two separate running containers.
|
||||
|
||||
You can start these images directly with `docker run` with this command:
|
||||
您可以使用 `docker run` 命令直接启动镜像,如下:
|
||||
|
||||
```bash
|
||||
docker run --name rustdesk-server \
|
||||
--net=host \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-v "$PWD/data:/data" -d rustdesk/rustdesk-server-s6:latest
|
||||
-v "$PWD/data:/data" -d lejianwen/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
or without `--net=host`, but P2P direct connection cannot work.
|
||||
或刪去 `--net=host` 参数, 但 P2P 直连功能将无法工作。
|
||||
|
||||
```bash
|
||||
docker run --name rustdesk-server \
|
||||
@@ -163,10 +222,10 @@ docker run --name rustdesk-server \
|
||||
-p 21117:21117 -p 21118:21118 -p 21119:21119 \
|
||||
-e "RELAY=rustdeskrelay.example.com" \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-v "$PWD/data:/data" -d rustdesk/rustdesk-server-s6:latest
|
||||
-v "$PWD/data:/data" -d lejianwen/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
Or you can use a docker-compose file:
|
||||
或着您也可以使用 docker-compose 文件:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
@@ -175,13 +234,14 @@ services:
|
||||
rustdesk-server:
|
||||
container_name: rustdesk-server
|
||||
ports:
|
||||
- 21114:21114
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server-s6:latest
|
||||
image: lejianwen/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- "RELAY=rustdesk.example.com:21117"
|
||||
- "ENCRYPTED_ONLY=1"
|
||||
@@ -190,26 +250,26 @@ services:
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
For this container image, you can use these environment variables, **in addition** to the ones specified in the following **ENV variables** section:
|
||||
对于此容器镜像,除了在下面的环境变量部分指定的变量之外,您还可以使用以下`环境变量`
|
||||
|
||||
| variable | optional | description |
|
||||
| --- | --- | --- |
|
||||
| RELAY | no | the IP address/DNS name of the machine running this container |
|
||||
| ENCRYPTED_ONLY | yes | if set to **"1"** unencrypted connection will not be accepted |
|
||||
| KEY_PUB | yes | public part of the key pair |
|
||||
| KEY_PRIV | yes | private part of the key pair |
|
||||
| 环境变量 | 是否可选 | 描述 |
|
||||
|----------------|------|--------------------------|
|
||||
| RELAY | 否 | 运行此容器的宿主机的 IP 地址/ DNS 名称 |
|
||||
| ENCRYPTED_ONLY | 是 | 如果设置为 **"1"**,将不接受未加密的连接。 |
|
||||
| KEY_PUB | 是 | 密钥对中的公钥(Public Key) |
|
||||
| KEY_PRIV | 是 | 密钥对中的私钥(Private Key) |
|
||||
|
||||
### Secret management in S6-overlay based images
|
||||
### 基于 S6-overlay 镜像的密钥管理
|
||||
|
||||
You can obviously keep the key pair in a docker volume, but the best practices tells you to not write the keys on the filesystem; so we provide a couple of options.
|
||||
您可以将密钥对保存在 Docker volume 中,但我们建议不要将密钥写入文件系統中;因此,我们提供了一些方案。
|
||||
|
||||
On container startup, the presence of the keypair is checked (`/data/id_ed25519.pub` and `/data/id_ed25519`) and if one of these keys doesn't exist, it's recreated from ENV variables or docker secrets.
|
||||
Then the validity of the keypair is checked: if public and private keys doesn't match, the container will stop.
|
||||
If you provide no keys, `hbbs` will generate one for you, and it'll place it in the default location.
|
||||
在容器启动时,会检查密钥对是否存在(`/data/id_ed25519.pub` 和 `/data/id_ed25519`),如果其中一個密钥不存在,则会从环境变量或 Docker Secret 中重新生成它。
|
||||
然后检查密钥对的可用性:如果公钥和私钥不匹配,容器将停止运行。
|
||||
如果您未提供密钥,`hbbs` 将会在默认位置生成一个。
|
||||
|
||||
#### Use ENV to store the key pair
|
||||
#### 使用 ENV 存储密钥对
|
||||
|
||||
You can use docker environment variables to store the keys. Just follow this examples:
|
||||
您可以使用 Docker 环境变量來存储密钥。如下:
|
||||
|
||||
```bash
|
||||
docker run --name rustdesk-server \
|
||||
@@ -219,7 +279,7 @@ docker run --name rustdesk-server \
|
||||
-e "DB_URL=/db/db_v2.sqlite3" \
|
||||
-e "KEY_PRIV=FR2j78IxfwJNR+HjLluQ2Nh7eEryEeIZCwiQDPVe+PaITKyShphHAsPLn7So0OqRs92nGvSRdFJnE2MSyrKTIQ==" \
|
||||
-e "KEY_PUB=iEyskoaYRwLDy5+0qNDqkbPdpxr0kXRSZxNjEsqykyE=" \
|
||||
-v "$PWD/db:/db" -d rustdesk/rustdesk-server-s6:latest
|
||||
-v "$PWD/db:/db" -d lejianwen/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
```yaml
|
||||
@@ -229,13 +289,14 @@ services:
|
||||
rustdesk-server:
|
||||
container_name: rustdesk-server
|
||||
ports:
|
||||
- 21114:21114
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server-s6:latest
|
||||
image: lejianwen/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- "RELAY=rustdesk.example.com:21117"
|
||||
- "ENCRYPTED_ONLY=1"
|
||||
@@ -247,11 +308,11 @@ services:
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
#### Use Docker secrets to store the key pair
|
||||
#### 使用 Docker Secret 來保存密钥对
|
||||
|
||||
You can alternatively use docker secrets to store the keys.
|
||||
This is useful if you're using **docker-compose** or **Docker Swarm**.
|
||||
Just follow this examples:
|
||||
您还可以使用 Docker Secret 來保存密钥。
|
||||
如果您使用 **docker-compose** 或 **docker swarm**,推荐您使用。
|
||||
只需按照以下示例操作:
|
||||
|
||||
```bash
|
||||
cat secrets/id_ed25519.pub | docker secret create key_pub -
|
||||
@@ -263,7 +324,7 @@ docker service create --name rustdesk-server \
|
||||
-e "ENCRYPTED_ONLY=1" \
|
||||
-e "DB_URL=/db/db_v2.sqlite3" \
|
||||
--mount "type=bind,source=$PWD/db,destination=/db" \
|
||||
rustdesk/rustdesk-server-s6:latest
|
||||
lejianwen/rustdesk-server-s6:latest
|
||||
```
|
||||
|
||||
```yaml
|
||||
@@ -273,13 +334,14 @@ services:
|
||||
rustdesk-server:
|
||||
container_name: rustdesk-server
|
||||
ports:
|
||||
- 21114:21114
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server-s6:latest
|
||||
image: lejianwen/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- "RELAY=rustdesk.example.com:21117"
|
||||
- "ENCRYPTED_ONLY=1"
|
||||
@@ -298,57 +360,55 @@ secrets:
|
||||
file: secrets/id_ed25519
|
||||
```
|
||||
|
||||
## How to create a keypair
|
||||
## 如何生成密钥对
|
||||
|
||||
A keypair is needed for encryption; you can provide it, as explained before, but you need a way to create one.
|
||||
加密需要一对密钥;您可以按照前面所述提供它,但需要一个工具去生成密钥对。
|
||||
|
||||
You can use this command to generate a keypair:
|
||||
您可以使用以下命令生成一对密钥:
|
||||
|
||||
```bash
|
||||
/usr/bin/rustdesk-utils genkeypair
|
||||
```
|
||||
|
||||
If you don't have (or don't want) the `rustdesk-utils` package installed on your system, you can invoke the same command with docker:
|
||||
如果您沒有(或不想)在系统上安装 `rustdesk-utils` 套件,您可以使用 Docker 执行相同的命令:
|
||||
|
||||
```bash
|
||||
docker run --rm --entrypoint /usr/bin/rustdesk-utils rustdesk/rustdesk-server-s6:latest genkeypair
|
||||
docker run --rm --entrypoint /usr/bin/rustdesk-utils lejianwen/rustdesk-server-s6:latest genkeypair
|
||||
```
|
||||
|
||||
The output will be something like this:
|
||||
运行后的输出内容如下:
|
||||
|
||||
```text
|
||||
Public Key: 8BLLhtzUBU/XKAH4mep3p+IX4DSApe7qbAwNH9nv4yA=
|
||||
Secret Key: egAVd44u33ZEUIDTtksGcHeVeAwywarEdHmf99KM5ajwEsuG3NQFT9coAfiZ6nen4hfgNICl7upsDA0f2e/jIA==
|
||||
```
|
||||
|
||||
## .deb packages
|
||||
## .deb 套件
|
||||
|
||||
Separate .deb packages are available for each binary, you can find them in the [Releases](https://github.com/rustdesk/rustdesk-server/releases).
|
||||
These packages are meant for the following distributions:
|
||||
每个可执行文件都有单独的 .deb 套件可供使用,您可以在 [releases](https://github.com/lejianwen/rustdesk-server/releases) 页面中找到它們。
|
||||
這些套件适用于以下发行版:
|
||||
|
||||
- Ubuntu 24.04 LTS
|
||||
- Ubuntu 22.04 LTS
|
||||
- Ubuntu 20.04 LTS
|
||||
- Ubuntu 18.04 LTS
|
||||
- Debian 12 bookworm
|
||||
- Debian 11 bullseye
|
||||
- Debian 10 buster
|
||||
|
||||
## ENV variables
|
||||
## ENV 环境变量
|
||||
|
||||
`hbbs` and `hbbr` can be configured using these ENV variables.
|
||||
You can specify the variables as usual or use an `.env` file.
|
||||
可以使用这些`环境变量`参数來配置 hbbs 和 hbbr。
|
||||
您可以像往常一样指定参数,或者使用 .env 文件。
|
||||
|
||||
| variable | binary | description |
|
||||
| --- | --- | --- |
|
||||
| ALWAYS_USE_RELAY | hbbs | if set to **"Y"** disallows direct peer connection |
|
||||
| DB_URL | hbbs | path for database file |
|
||||
| DOWNGRADE_START_CHECK | hbbr | delay (in seconds) before downgrade check |
|
||||
| DOWNGRADE_THRESHOLD | hbbr | threshold of downgrade check (bit/ms) |
|
||||
| KEY | hbbs/hbbr | if set force the use of a specific key, if set to **"_"** force the use of any key |
|
||||
| LIMIT_SPEED | hbbr | speed limit (in Mb/s) |
|
||||
| PORT | hbbs/hbbr | listening port (21116 for hbbs - 21117 for hbbr) |
|
||||
| RELAY | hbbs | IP address/DNS name of the machines running hbbr (separated by comma) |
|
||||
| RUST_LOG | all | set debug level (error\|warn\|info\|debug\|trace) |
|
||||
| SINGLE_BANDWIDTH | hbbr | max bandwidth for a single connection (in Mb/s) |
|
||||
| TOTAL_BANDWIDTH | hbbr | max total bandwidth (in Mb/s) |
|
||||
| 参数 | 可执行文件 | 描述 |
|
||||
|-----------------------|---------------|--------------------------------------------------|
|
||||
| ALWAYS_USE_RELAY | hbbs | 如果设定为 **"Y"**,将关闭直接点对点连接功能 |
|
||||
| DB_URL | hbbs | 数据库配置 |
|
||||
| DOWNGRADE_START_CHECK | hbbr | 降级检查之前的延迟是啊尽(以秒为单位) |
|
||||
| DOWNGRADE_THRESHOLD | hbbr | 降级检查的阈值(bit/ms) |
|
||||
| KEY | hbbs/hbbr | 如果设置了此参数,将强制使用指定密钥对,如果设为 **"_"**,则强制使用任意密钥 |
|
||||
| LIMIT_SPEED | hbbr | 速度限制(以Mb/s为单位) |
|
||||
| PORT | hbbs/hbbr | 监听端口(hbbs为21116,hbbr为21117) |
|
||||
| RELAY_SERVERS | hbbs | 运行hbbr的机器的IP地址/DNS名称(用逗号分隔) |
|
||||
| RUST_LOG | all | 设置 debug level (error\|warn\|info\|debug\|trace) |
|
||||
| SINGLE_BANDWIDTH | hbbr | 单个连接的最大带宽(以Mb/s为单位) |
|
||||
| TOTAL_BANDWIDTH | hbbr | 最大总带宽(以Mb/s为单位) |
|
||||
+16
-23
@@ -1,36 +1,29 @@
|
||||
version: '3'
|
||||
|
||||
networks:
|
||||
rustdesk-net:
|
||||
external: false
|
||||
|
||||
services:
|
||||
hbbs:
|
||||
container_name: hbbs
|
||||
rustdesk:
|
||||
ports:
|
||||
- 21114:21114
|
||||
- 21115:21115
|
||||
- 21116:21116
|
||||
- 21116:21116/udp
|
||||
- 21118:21118
|
||||
image: rustdesk/rustdesk-server:latest
|
||||
command: hbbs -r rustdesk.example.com:21117
|
||||
volumes:
|
||||
- ./data:/root
|
||||
networks:
|
||||
- rustdesk-net
|
||||
depends_on:
|
||||
- hbbr
|
||||
restart: unless-stopped
|
||||
|
||||
hbbr:
|
||||
container_name: hbbr
|
||||
ports:
|
||||
- 21117:21117
|
||||
- 21118:21118
|
||||
- 21119:21119
|
||||
image: rustdesk/rustdesk-server:latest
|
||||
command: hbbr
|
||||
image: lejianwen/rustdesk-server-s6:latest
|
||||
environment:
|
||||
- RELAY=<relay_server[:port]>
|
||||
- ENCRYPTED_ONLY=1
|
||||
- MUST_LOGIN=N
|
||||
- TZ=Asia/Shanghai
|
||||
- RUSTDESK_API_RUSTDESK_ID_SERVER=<id_server[:21116]>
|
||||
- RUSTDESK_API_RUSTDESK_RELAY_SERVER=<relay_server[:21117]>
|
||||
- RUSTDESK_API_RUSTDESK_API_SERVER=http://<api_server[:21114]>
|
||||
volumes:
|
||||
- ./data:/root
|
||||
- /data/rustdesk/server:/data
|
||||
- /data/rustdesk/api:/app/data #将数据库挂载
|
||||
- /data/rustdesk/server:/app/conf/data #挂载key文件到api容器,可以不用使用 RUSTDESK_API_RUSTDESK_KEY
|
||||
networks:
|
||||
- rustdesk-net
|
||||
restart: unless-stopped
|
||||
restart: unless-stopped
|
||||
+5
-3
@@ -1,4 +1,4 @@
|
||||
FROM busybox:stable
|
||||
FROM lejianwen/rustdesk-api:latest
|
||||
|
||||
ARG S6_OVERLAY_VERSION=3.2.0.0
|
||||
ARG S6_ARCH=x86_64
|
||||
@@ -15,11 +15,13 @@ COPY rootfs /
|
||||
ENV RELAY=relay.example.com
|
||||
ENV ENCRYPTED_ONLY=0
|
||||
|
||||
EXPOSE 21115 21116 21116/udp 21117 21118 21119
|
||||
EXPOSE 21114 21115 21116 21116/udp 21117 21118 21119
|
||||
|
||||
HEALTHCHECK --interval=10s --timeout=5s CMD /usr/bin/healthcheck.sh
|
||||
|
||||
WORKDIR /data
|
||||
WORKDIR /app
|
||||
|
||||
VOLUME /app/data
|
||||
|
||||
VOLUME /data
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
key-secret
|
||||
hbbs
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/command/with-contenv sh
|
||||
sleep 3
|
||||
cd /app
|
||||
./apimain
|
||||
@@ -0,0 +1 @@
|
||||
longrun
|
||||
@@ -1 +0,0 @@
|
||||
83419b6549636ee39dacef7776c473f5802e08d6
|
||||
Submodule
+1
Submodule libs/hbb_common added at d6b14975ff
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
+54
@@ -0,0 +1,54 @@
|
||||
use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header, Validation};
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::env;
|
||||
pub static SECRET: Lazy<String> =
|
||||
Lazy::new(|| env::var("RUSTDESK_API_JWT_KEY").unwrap_or_else(|_| "".to_string()));
|
||||
|
||||
// 定义一个结构体来表示 JWT 的 payload
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Claims {
|
||||
user_id: u32,
|
||||
exp: usize,
|
||||
}
|
||||
|
||||
pub fn generate_token(user_id: u32, exp: i64) -> Result<String, String> {
|
||||
println!("secret: {:}", SECRET.to_string());
|
||||
let claims = Claims {
|
||||
user_id,
|
||||
exp: (chrono::Utc::now() + chrono::Duration::seconds(exp)).timestamp() as usize,
|
||||
};
|
||||
|
||||
let token = encode(
|
||||
&Header::default(),
|
||||
&claims,
|
||||
&EncodingKey::from_secret(SECRET.as_ref()),
|
||||
);
|
||||
|
||||
match token {
|
||||
Ok(t) => Ok(t),
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
}
|
||||
// 验证 JWT 的函数
|
||||
pub fn verify_token(token: &str) -> Result<Claims, String> {
|
||||
// 解码 JWT
|
||||
let validation = Validation::new(Algorithm::HS256);
|
||||
|
||||
let decoded = decode::<Claims>(
|
||||
&token,
|
||||
&DecodingKey::from_secret(SECRET.as_ref()),
|
||||
&validation,
|
||||
);
|
||||
match decoded {
|
||||
Ok(token_data) => {
|
||||
let now = chrono::Utc::now().timestamp() as usize;
|
||||
if token_data.claims.exp > now {
|
||||
Ok(token_data.claims)
|
||||
} else {
|
||||
Err("Token status invalid or expired".to_string())
|
||||
}
|
||||
}
|
||||
Err(_) => Err("Invalid token".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,4 @@ pub mod common;
|
||||
mod database;
|
||||
mod peer;
|
||||
mod version;
|
||||
pub mod jwt;
|
||||
+2
-1
@@ -22,7 +22,8 @@ fn main() -> ResultType<()> {
|
||||
-r, --relay-servers=[HOST] 'Sets the default relay servers, separated by comma'
|
||||
-M, --rmem=[NUMBER(default={RMEM})] 'Sets UDP recv buffer size, set system rmem_max first, e.g., sudo sysctl -w net.core.rmem_max=52428800. vi /etc/sysctl.conf, net.core.rmem_max=52428800, sudo sysctl –p'
|
||||
, --mask=[MASK] 'Determine if the connection comes from LAN, e.g. 192.168.0.0/16'
|
||||
-k, --key=[KEY] 'Only allow the client with the same key'",
|
||||
-k, --key=[KEY] 'Only allow the client with the same key'
|
||||
, --must-login=[Y|N] 'Only allow the client with login'",
|
||||
);
|
||||
init_args(&args, "hbbs", "RustDesk ID/Rendezvous Server");
|
||||
let port = get_arg_or("port", RENDEZVOUS_PORT.to_string()).parse::<i32>()?;
|
||||
|
||||
+425
-130
@@ -1,5 +1,6 @@
|
||||
use crate::common::*;
|
||||
use crate::peer::*;
|
||||
use hbb_common::bytes::BufMut;
|
||||
use hbb_common::{
|
||||
allow_err, bail,
|
||||
bytes::{Bytes, BytesMut},
|
||||
@@ -13,9 +14,15 @@ use hbb_common::{
|
||||
log,
|
||||
protobuf::{Message as _, MessageField},
|
||||
rendezvous_proto::{
|
||||
register_pk_response::Result::{TOO_FREQUENT, UUID_MISMATCH},
|
||||
register_pk_response::Result::{INVALID_ID_FORMAT, TOO_FREQUENT, UUID_MISMATCH},
|
||||
*,
|
||||
},
|
||||
sodiumoxide::crypto::{
|
||||
box_, box_::PublicKey, box_::SecretKey, secretbox, secretbox::Key, secretbox::Nonce, sign,
|
||||
},
|
||||
sodiumoxide::hex,
|
||||
tcp,
|
||||
tcp::Encrypt,
|
||||
tcp::{listen_any, FramedStream},
|
||||
timeout,
|
||||
tokio::{
|
||||
@@ -31,7 +38,9 @@ use hbb_common::{
|
||||
AddrMangle, ResultType,
|
||||
};
|
||||
use ipnetwork::Ipv4Network;
|
||||
use sodiumoxide::crypto::sign;
|
||||
|
||||
use crate::jwt;
|
||||
use std::io::Error;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
||||
@@ -50,9 +59,43 @@ enum Data {
|
||||
const REG_TIMEOUT: i32 = 30_000;
|
||||
type TcpStreamSink = SplitSink<Framed<TcpStream, BytesCodec>, Bytes>;
|
||||
type WsSink = SplitSink<tokio_tungstenite::WebSocketStream<TcpStream>, tungstenite::Message>;
|
||||
struct SafeWsSink {
|
||||
sink: WsSink,
|
||||
encrypt: Option<Encrypt>,
|
||||
}
|
||||
|
||||
struct SafeTcpStreamSink {
|
||||
sink: TcpStreamSink,
|
||||
encrypt: Option<Encrypt>,
|
||||
}
|
||||
enum Sink {
|
||||
TcpStream(TcpStreamSink),
|
||||
Ws(WsSink),
|
||||
// TcpStream(TcpStreamSink),
|
||||
// Ws(WsSink),
|
||||
Wss(SafeWsSink),
|
||||
Tss(SafeTcpStreamSink),
|
||||
}
|
||||
|
||||
impl Sink {
|
||||
async fn send(&mut self, msg: &RendezvousMessage) {
|
||||
if let Ok(mut bytes) = msg.write_to_bytes() {
|
||||
match self {
|
||||
// Sink::TcpStream(mut s) => allow_err!(s.send(Bytes::from(bytes)).await),
|
||||
// Sink::Ws(mut s) => allow_err!(s.send(tungstenite::Message::Binary(bytes)).await),
|
||||
Sink::Wss(s) => {
|
||||
if let Some(key) = s.encrypt.as_mut() {
|
||||
bytes = key.enc(&bytes);
|
||||
}
|
||||
allow_err!(s.sink.send(tungstenite::Message::Binary(bytes)).await)
|
||||
}
|
||||
Sink::Tss(s) => {
|
||||
if let Some(key) = s.encrypt.as_mut() {
|
||||
bytes = key.enc(&bytes);
|
||||
}
|
||||
allow_err!(s.sink.send(Bytes::from(bytes)).await)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type Sender = mpsc::UnboundedSender<Data>;
|
||||
type Receiver = mpsc::UnboundedReceiver<Data>;
|
||||
@@ -60,6 +103,7 @@ static ROTATION_RELAY_SERVER: AtomicUsize = AtomicUsize::new(0);
|
||||
type RelayServers = Vec<String>;
|
||||
const CHECK_RELAY_TIMEOUT: u64 = 3_000;
|
||||
static ALWAYS_USE_RELAY: AtomicBool = AtomicBool::new(false);
|
||||
static MUST_LOGIN: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Inner {
|
||||
@@ -69,6 +113,8 @@ struct Inner {
|
||||
mask: Option<Ipv4Network>,
|
||||
local_ip: String,
|
||||
sk: Option<sign::SecretKey>,
|
||||
secure_tcp_pk_b: PublicKey,
|
||||
secure_tcp_sk_b: SecretKey,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -80,6 +126,7 @@ pub struct RendezvousServer {
|
||||
relay_servers0: Arc<RelayServers>,
|
||||
rendezvous_servers: Arc<Vec<String>>,
|
||||
inner: Arc<Inner>,
|
||||
ws_map: Arc<Mutex<HashMap<SocketAddr, Sink>>>,
|
||||
}
|
||||
|
||||
enum LoopFailure {
|
||||
@@ -119,6 +166,8 @@ impl RendezvousServer {
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
};
|
||||
// For privacy use per connection key pair
|
||||
let (secure_tcp_pk_b, secure_tcp_sk_b) = box_::gen_keypair();
|
||||
let mut rs = Self {
|
||||
tcp_punch: Arc::new(Mutex::new(HashMap::new())),
|
||||
pm,
|
||||
@@ -133,7 +182,10 @@ impl RendezvousServer {
|
||||
sk,
|
||||
mask,
|
||||
local_ip,
|
||||
secure_tcp_pk_b,
|
||||
secure_tcp_sk_b,
|
||||
}),
|
||||
ws_map: Arc::new(Mutex::new(HashMap::new())),
|
||||
};
|
||||
log::info!("mask: {:?}", rs.inner.mask);
|
||||
log::info!("local-ip: {:?}", rs.inner.local_ip);
|
||||
@@ -158,6 +210,27 @@ impl RendezvousServer {
|
||||
"N"
|
||||
}
|
||||
);
|
||||
|
||||
let must_login = get_arg("must-login");
|
||||
log::debug!("must_login={}", must_login);
|
||||
if must_login.to_uppercase() == "Y"
|
||||
|| (must_login == ""
|
||||
&& std::env::var("MUST_LOGIN")
|
||||
.unwrap_or_default()
|
||||
.to_uppercase()
|
||||
== "Y")
|
||||
{
|
||||
MUST_LOGIN.store(true, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
log::info!(
|
||||
"MUST_LOGIN={}",
|
||||
if MUST_LOGIN.load(Ordering::SeqCst) {
|
||||
"Y"
|
||||
} else {
|
||||
"N"
|
||||
}
|
||||
);
|
||||
if test_addr.to_lowercase() != "no" {
|
||||
let test_addr = if test_addr.is_empty() {
|
||||
listener.local_addr()?
|
||||
@@ -319,7 +392,13 @@ impl RendezvousServer {
|
||||
// B registered
|
||||
if !rp.id.is_empty() {
|
||||
log::trace!("New peer registered: {:?} {:?}", &rp.id, &addr);
|
||||
self.update_addr(rp.id, addr, socket).await?;
|
||||
let request_pk = self.update_addr(rp.id, addr).await;
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_peer_response(RegisterPeerResponse {
|
||||
request_pk,
|
||||
..Default::default()
|
||||
});
|
||||
socket.send(&msg_out, addr).await?;
|
||||
if self.inner.serial > rp.serial {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_configure_update(ConfigUpdate {
|
||||
@@ -332,89 +411,25 @@ impl RendezvousServer {
|
||||
}
|
||||
}
|
||||
Some(rendezvous_message::Union::RegisterPk(rk)) => {
|
||||
if rk.uuid.is_empty() || rk.pk.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let id = rk.id;
|
||||
let ip = addr.ip().to_string();
|
||||
if id.len() < 6 {
|
||||
return send_rk_res(socket, addr, UUID_MISMATCH).await;
|
||||
} else if !self.check_ip_blocker(&ip, &id).await {
|
||||
return send_rk_res(socket, addr, TOO_FREQUENT).await;
|
||||
}
|
||||
let peer = self.pm.get_or(&id).await;
|
||||
let (changed, ip_changed) = {
|
||||
let peer = peer.read().await;
|
||||
if peer.uuid.is_empty() {
|
||||
(true, false)
|
||||
} else {
|
||||
if peer.uuid == rk.uuid {
|
||||
if peer.info.ip != ip && peer.pk != rk.pk {
|
||||
log::warn!(
|
||||
"Peer {} ip/pk mismatch: {}/{:?} vs {}/{:?}",
|
||||
id,
|
||||
ip,
|
||||
rk.pk,
|
||||
peer.info.ip,
|
||||
peer.pk,
|
||||
);
|
||||
drop(peer);
|
||||
return send_rk_res(socket, addr, UUID_MISMATCH).await;
|
||||
}
|
||||
} else {
|
||||
log::warn!(
|
||||
"Peer {} uuid mismatch: {:?} vs {:?}",
|
||||
id,
|
||||
rk.uuid,
|
||||
peer.uuid
|
||||
);
|
||||
drop(peer);
|
||||
return send_rk_res(socket, addr, UUID_MISMATCH).await;
|
||||
}
|
||||
let ip_changed = peer.info.ip != ip;
|
||||
(
|
||||
peer.uuid != rk.uuid || peer.pk != rk.pk || ip_changed,
|
||||
ip_changed,
|
||||
)
|
||||
let response = self.handle_register_pk(rk, addr, false).await;
|
||||
match response {
|
||||
Err(err) => {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_pk_response(RegisterPkResponse {
|
||||
result: err.into(),
|
||||
..Default::default()
|
||||
});
|
||||
socket.send(&msg_out, addr).await?;
|
||||
}
|
||||
};
|
||||
let mut req_pk = peer.read().await.reg_pk;
|
||||
if req_pk.1.elapsed().as_secs() > 6 {
|
||||
req_pk.0 = 0;
|
||||
} else if req_pk.0 > 2 {
|
||||
return send_rk_res(socket, addr, TOO_FREQUENT).await;
|
||||
}
|
||||
req_pk.0 += 1;
|
||||
req_pk.1 = Instant::now();
|
||||
peer.write().await.reg_pk = req_pk;
|
||||
if ip_changed {
|
||||
let mut lock = IP_CHANGES.lock().await;
|
||||
if let Some((tm, ips)) = lock.get_mut(&id) {
|
||||
if tm.elapsed().as_secs() > IP_CHANGE_DUR {
|
||||
*tm = Instant::now();
|
||||
ips.clear();
|
||||
ips.insert(ip.clone(), 1);
|
||||
} else if let Some(v) = ips.get_mut(&ip) {
|
||||
*v += 1;
|
||||
} else {
|
||||
ips.insert(ip.clone(), 1);
|
||||
}
|
||||
} else {
|
||||
lock.insert(
|
||||
id.clone(),
|
||||
(Instant::now(), HashMap::from([(ip.clone(), 1)])),
|
||||
);
|
||||
Ok(res) => {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_pk_response(RegisterPkResponse {
|
||||
result: res.into(),
|
||||
..Default::default()
|
||||
});
|
||||
socket.send(&msg_out, addr).await?;
|
||||
}
|
||||
}
|
||||
if changed {
|
||||
self.pm.update_pk(id, peer, addr, rk.uuid, rk.pk, ip).await;
|
||||
}
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_pk_response(RegisterPkResponse {
|
||||
result: register_pk_response::Result::OK.into(),
|
||||
..Default::default()
|
||||
});
|
||||
socket.send(&msg_out, addr).await?
|
||||
}
|
||||
Some(rendezvous_message::Union::PunchHoleRequest(ph)) => {
|
||||
if self.pm.is_in_memory(&ph.id).await {
|
||||
@@ -481,7 +496,30 @@ impl RendezvousServer {
|
||||
ws: bool,
|
||||
) -> bool {
|
||||
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(bytes) {
|
||||
// log::debug!("Received TCP message from {}: {:?}", addr, msg_in);
|
||||
match msg_in.union {
|
||||
Some(rendezvous_message::Union::RegisterPeer(rp)) => {
|
||||
// B registered
|
||||
if !rp.id.is_empty() {
|
||||
log::trace!("New peer registered: {:?} {:?}", &rp.id, &addr);
|
||||
let request_pk = self.update_addr(rp.id, addr).await;
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_peer_response(RegisterPeerResponse {
|
||||
request_pk,
|
||||
..Default::default()
|
||||
});
|
||||
Self::send_to_sink(sink, msg_out).await;
|
||||
if self.inner.serial > rp.serial {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_configure_update(ConfigUpdate {
|
||||
serial: self.inner.serial,
|
||||
rendezvous_servers: (*self.rendezvous_servers).clone(),
|
||||
..Default::default()
|
||||
});
|
||||
Self::send_to_sink(sink, msg_out).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(rendezvous_message::Union::PunchHoleRequest(ph)) => {
|
||||
// there maybe several attempt, so sink can be none
|
||||
if let Some(sink) = sink.take() {
|
||||
@@ -545,11 +583,74 @@ impl RendezvousServer {
|
||||
msg_out.set_test_nat_response(res);
|
||||
Self::send_to_sink(sink, msg_out).await;
|
||||
}
|
||||
Some(rendezvous_message::Union::RegisterPk(_)) => {
|
||||
let res = register_pk_response::Result::NOT_SUPPORT;
|
||||
Some(rendezvous_message::Union::RegisterPk(rk)) => {
|
||||
let response = self.handle_register_pk(rk, addr, ws).await;
|
||||
match response {
|
||||
Err(err) => {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_pk_response(RegisterPkResponse {
|
||||
result: err.into(),
|
||||
..Default::default()
|
||||
});
|
||||
Self::send_to_sink(sink, msg_out).await;
|
||||
return false;
|
||||
}
|
||||
Ok(res) => {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_pk_response(RegisterPkResponse {
|
||||
result: res.into(),
|
||||
..Default::default()
|
||||
});
|
||||
Self::send_to_sink(sink, msg_out).await;
|
||||
if ws {
|
||||
// for ws, we can only get addr when register_pk
|
||||
if let Some(sink) = sink.take() {
|
||||
self.ws_map.lock().await.insert(try_into_v4(addr), sink);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(rendezvous_message::Union::KeyExchange(ex)) => {
|
||||
log::trace!("KeyExchange {:?} <- bytes: {:?}", addr, hex::encode(&bytes));
|
||||
if ex.keys.len() != 2 {
|
||||
log::error!("Handshake failed: invalid phase 2 key exchange message");
|
||||
return false;
|
||||
}
|
||||
log::trace!("KeyExchange their_pk: {:?}", hex::encode(&ex.keys[0]));
|
||||
log::trace!("KeyExchange box: {:?}", hex::encode(&ex.keys[1]));
|
||||
let their_pk: [u8; 32] = ex.keys[0].to_vec().try_into().unwrap();
|
||||
let cryptobox: [u8; 48] = ex.keys[1].to_vec().try_into().unwrap();
|
||||
let symetric_key = get_symetric_key_from_msg(
|
||||
self.inner.secure_tcp_sk_b.0,
|
||||
their_pk,
|
||||
&cryptobox,
|
||||
);
|
||||
log::debug!("KeyExchange symetric key: {:?}", hex::encode(&symetric_key));
|
||||
let key = secretbox::Key::from_slice(&symetric_key);
|
||||
match key {
|
||||
Some(key) => {
|
||||
if let Some(sink) = sink.as_mut() {
|
||||
match sink {
|
||||
Sink::Wss(s) => s.encrypt = Some(Encrypt::new(key)),
|
||||
Sink::Tss(s) => s.encrypt = Some(Encrypt::new(key)),
|
||||
}
|
||||
}
|
||||
log::debug!("KeyExchange symetric key set");
|
||||
return true;
|
||||
}
|
||||
None => {
|
||||
log::error!("KeyExchange symetric key NOT set");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(rendezvous_message::Union::OnlineRequest(or)) => {
|
||||
let mut states = self.peers_online_state(or.peers).await;
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_pk_response(RegisterPkResponse {
|
||||
result: res.into(),
|
||||
msg_out.set_online_response(OnlineResponse {
|
||||
states: states.into(),
|
||||
..Default::default()
|
||||
});
|
||||
Self::send_to_sink(sink, msg_out).await;
|
||||
@@ -560,13 +661,122 @@ impl RendezvousServer {
|
||||
false
|
||||
}
|
||||
|
||||
#[inline]
|
||||
async fn update_addr(
|
||||
async fn peers_online_state(&mut self, peers: Vec<String>) -> BytesMut {
|
||||
let mut states = BytesMut::zeroed((peers.len() + 7) / 8);
|
||||
for (i, peer_id) in peers.iter().enumerate() {
|
||||
if let Some(peer) = self.pm.get_in_memory(peer_id).await {
|
||||
let elapsed = peer.read().await.last_reg_time.elapsed().as_millis() as i32;
|
||||
// bytes index from left to right
|
||||
let states_idx = i / 8;
|
||||
let bit_idx = 7 - i % 8;
|
||||
if elapsed < REG_TIMEOUT {
|
||||
states[states_idx] |= 0x01 << bit_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
states
|
||||
}
|
||||
|
||||
async fn handle_register_pk(
|
||||
&mut self,
|
||||
id: String,
|
||||
socket_addr: SocketAddr,
|
||||
socket: &mut FramedSocket,
|
||||
) -> ResultType<()> {
|
||||
rk: RegisterPk,
|
||||
addr: SocketAddr,
|
||||
ws: bool,
|
||||
) -> Result<register_pk_response::Result, register_pk_response::Result> {
|
||||
if rk.uuid.is_empty() || rk.pk.is_empty() {
|
||||
return Err(INVALID_ID_FORMAT);
|
||||
}
|
||||
let id = rk.id;
|
||||
let ip = addr.ip().to_string();
|
||||
if id.len() < 6 {
|
||||
return Err(UUID_MISMATCH);
|
||||
//return Err(send_rk_res(socket, addr, UUID_MISMATCH).await);
|
||||
} else if !self.check_ip_blocker(&ip, &id).await {
|
||||
return Err(TOO_FREQUENT);
|
||||
//return Err(send_rk_res(socket, addr, TOO_FREQUENT).await);
|
||||
}
|
||||
let peer = self.pm.get_or(&id).await;
|
||||
let (changed, ip_changed) = {
|
||||
let peer = peer.read().await;
|
||||
if peer.uuid.is_empty() {
|
||||
(true, false)
|
||||
} else {
|
||||
if peer.uuid == rk.uuid {
|
||||
if peer.info.ip != ip && peer.pk != rk.pk {
|
||||
log::warn!(
|
||||
"Peer {} ip/pk mismatch: {}/{:?} vs {}/{:?}",
|
||||
id,
|
||||
ip,
|
||||
rk.pk,
|
||||
peer.info.ip,
|
||||
peer.pk,
|
||||
);
|
||||
drop(peer);
|
||||
return Err(UUID_MISMATCH);
|
||||
//return Err(send_rk_res(socket, addr, UUID_MISMATCH).await);
|
||||
}
|
||||
} else {
|
||||
log::warn!(
|
||||
"Peer {} uuid mismatch: {:?} vs {:?}",
|
||||
id,
|
||||
rk.uuid,
|
||||
peer.uuid
|
||||
);
|
||||
drop(peer);
|
||||
return Err(UUID_MISMATCH);
|
||||
//return Err(send_rk_res(socket, addr, UUID_MISMATCH).await);
|
||||
}
|
||||
let ip_changed = peer.info.ip != ip;
|
||||
(
|
||||
peer.uuid != rk.uuid || peer.pk != rk.pk || ip_changed,
|
||||
ip_changed,
|
||||
)
|
||||
}
|
||||
};
|
||||
let mut req_pk = peer.read().await.reg_pk;
|
||||
if req_pk.1.elapsed().as_secs() > 6 {
|
||||
req_pk.0 = 0;
|
||||
} else if req_pk.0 > 2 {
|
||||
return Err(TOO_FREQUENT);
|
||||
//return Err(send_rk_res(socket, addr, TOO_FREQUENT).await);
|
||||
}
|
||||
req_pk.0 += 1;
|
||||
req_pk.1 = Instant::now();
|
||||
peer.write().await.reg_pk = req_pk;
|
||||
if ip_changed {
|
||||
let mut lock = IP_CHANGES.lock().await;
|
||||
if let Some((tm, ips)) = lock.get_mut(&id) {
|
||||
if tm.elapsed().as_secs() > IP_CHANGE_DUR {
|
||||
*tm = Instant::now();
|
||||
ips.clear();
|
||||
ips.insert(ip.clone(), 1);
|
||||
} else if let Some(v) = ips.get_mut(&ip) {
|
||||
*v += 1;
|
||||
} else {
|
||||
ips.insert(ip.clone(), 1);
|
||||
}
|
||||
} else {
|
||||
lock.insert(
|
||||
id.clone(),
|
||||
(Instant::now(), HashMap::from([(ip.clone(), 1)])),
|
||||
);
|
||||
}
|
||||
}
|
||||
if changed || ws {
|
||||
// update peer info,解决tcp过程中不更新在线时间的问题
|
||||
self.pm.update_pk(id, peer, addr, rk.uuid, rk.pk, ip).await;
|
||||
}
|
||||
Ok(register_pk_response::Result::OK)
|
||||
// let mut msg_out = RendezvousMessage::new();
|
||||
// msg_out.set_register_pk_response(RegisterPkResponse {
|
||||
// result: register_pk_response::Result::OK.into(),
|
||||
// ..Default::default()
|
||||
// });
|
||||
// Ok(msg_out)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
async fn update_addr(&mut self, id: String, socket_addr: SocketAddr) -> bool {
|
||||
let (request_pk, ip_change) = if let Some(old) = self.pm.get_in_memory(&id).await {
|
||||
let mut old = old.write().await;
|
||||
let ip = socket_addr.ip();
|
||||
@@ -596,12 +806,13 @@ impl RendezvousServer {
|
||||
if let Some(old) = ip_change {
|
||||
log::info!("IP change of {} from {} to {}", id, old, socket_addr);
|
||||
}
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_peer_response(RegisterPeerResponse {
|
||||
request_pk,
|
||||
..Default::default()
|
||||
});
|
||||
socket.send(&msg_out, socket_addr).await
|
||||
request_pk
|
||||
// let mut msg_out = RendezvousMessage::new();
|
||||
// msg_out.set_register_peer_response(RegisterPeerResponse {
|
||||
// request_pk,
|
||||
// ..Default::default()
|
||||
// });
|
||||
// socket.send(&msg_out, socket_addr).await
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -687,6 +898,29 @@ impl RendezvousServer {
|
||||
});
|
||||
return Ok((msg_out, None));
|
||||
}
|
||||
// if secret is not empty check token by jwt
|
||||
if MUST_LOGIN.load(Ordering::SeqCst) {
|
||||
if ph.token.is_empty() {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_punch_hole_response(PunchHoleResponse {
|
||||
other_failure: String::from("Connection failed, please login!"),
|
||||
..Default::default()
|
||||
});
|
||||
return Ok((msg_out, None));
|
||||
} else if !jwt::SECRET.is_empty() {
|
||||
let token = ph.token;
|
||||
let token = jwt::verify_token(token.as_str());
|
||||
if token.is_err() {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_punch_hole_response(PunchHoleResponse {
|
||||
//提示重新登录
|
||||
other_failure: String::from("Token error, please log out and log back in!"),
|
||||
..Default::default()
|
||||
});
|
||||
return Ok((msg_out, None));
|
||||
}
|
||||
}
|
||||
}
|
||||
let id = ph.id;
|
||||
// punch hole request from A, relay to B,
|
||||
// check if in same intranet first,
|
||||
@@ -752,6 +986,7 @@ impl RendezvousServer {
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
//
|
||||
Ok((msg_out, Some(peer_addr)))
|
||||
} else {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
@@ -769,18 +1004,7 @@ impl RendezvousServer {
|
||||
stream: &mut FramedStream,
|
||||
peers: Vec<String>,
|
||||
) -> ResultType<()> {
|
||||
let mut states = BytesMut::zeroed((peers.len() + 7) / 8);
|
||||
for (i, peer_id) in peers.iter().enumerate() {
|
||||
if let Some(peer) = self.pm.get_in_memory(peer_id).await {
|
||||
let elapsed = peer.read().await.last_reg_time.elapsed().as_millis() as i32;
|
||||
// bytes index from left to right
|
||||
let states_idx = i / 8;
|
||||
let bit_idx = 7 - i % 8;
|
||||
if elapsed < REG_TIMEOUT {
|
||||
states[states_idx] |= 0x01 << bit_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut states = self.peers_online_state(peers).await;
|
||||
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_online_response(OnlineResponse {
|
||||
@@ -803,16 +1027,7 @@ impl RendezvousServer {
|
||||
#[inline]
|
||||
async fn send_to_sink(sink: &mut Option<Sink>, msg: RendezvousMessage) {
|
||||
if let Some(sink) = sink.as_mut() {
|
||||
if let Ok(bytes) = msg.write_to_bytes() {
|
||||
match sink {
|
||||
Sink::TcpStream(s) => {
|
||||
allow_err!(s.send(Bytes::from(bytes)).await);
|
||||
}
|
||||
Sink::Ws(ws) => {
|
||||
allow_err!(ws.send(tungstenite::Message::Binary(bytes)).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
sink.send(&msg).await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,7 +1052,12 @@ impl RendezvousServer {
|
||||
) -> ResultType<()> {
|
||||
let (msg, to_addr) = self.handle_punch_hole_request(addr, ph, key, ws).await?;
|
||||
if let Some(addr) = to_addr {
|
||||
self.tx.send(Data::Msg(msg.into(), addr))?;
|
||||
let mut sink = self.ws_map.lock().await.remove(&try_into_v4(addr));
|
||||
if let Some(s) = sink.as_mut() {
|
||||
s.send(&msg).await;
|
||||
} else {
|
||||
self.tx.send(Data::Msg(msg.into(), addr))?;
|
||||
}
|
||||
} else {
|
||||
self.send_to_tcp_sync(msg, addr).await?;
|
||||
}
|
||||
@@ -916,13 +1136,14 @@ impl RendezvousServer {
|
||||
match fds.next() {
|
||||
Some("h") => {
|
||||
res = format!(
|
||||
"{}\n{}\n{}\n{}\n{}\n{}\n",
|
||||
"{}\n{}\n{}\n{}\n{}\n{}\n{}\n",
|
||||
"relay-servers(rs) <separated by ,>",
|
||||
"reload-geo(rg)",
|
||||
"ip-blocker(ib) [<ip>|<number>] [-]",
|
||||
"ip-changes(ic) [<id>|<number>] [-]",
|
||||
"always-use-relay(aur)",
|
||||
"test-geo(tg) <ip1> <ip2>"
|
||||
"always-use-relay(aur) [Y|N]",
|
||||
"test-geo(tg) <ip1> <ip2>",
|
||||
"must-login(ml) [Y|N]",
|
||||
)
|
||||
}
|
||||
Some("relay-servers" | "rs") => {
|
||||
@@ -1049,6 +1270,17 @@ impl RendezvousServer {
|
||||
}
|
||||
}
|
||||
}
|
||||
Some("must-login" | "ml") => {
|
||||
if let Some(rs) = fds.next() {
|
||||
if rs.to_uppercase() == "Y" {
|
||||
MUST_LOGIN.store(true, Ordering::SeqCst);
|
||||
} else {
|
||||
MUST_LOGIN.store(false, Ordering::SeqCst);
|
||||
}
|
||||
} else {
|
||||
let _ = writeln!(res, "MUST_LOGIN: {:?}", MUST_LOGIN.load(Ordering::SeqCst));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
res
|
||||
@@ -1131,7 +1363,10 @@ impl RendezvousServer {
|
||||
};
|
||||
let ws_stream = tokio_tungstenite::accept_hdr_async(stream, callback).await?;
|
||||
let (a, mut b) = ws_stream.split();
|
||||
sink = Some(Sink::Ws(a));
|
||||
sink = Some(Sink::Wss(SafeWsSink {
|
||||
sink: a,
|
||||
encrypt: None,
|
||||
}));
|
||||
while let Ok(Some(Ok(msg))) = timeout(30_000, b.next()).await {
|
||||
if let tungstenite::Message::Binary(bytes) = msg {
|
||||
if !self.handle_tcp(&bytes, &mut sink, addr, key, ws).await {
|
||||
@@ -1141,8 +1376,24 @@ impl RendezvousServer {
|
||||
}
|
||||
} else {
|
||||
let (a, mut b) = Framed::new(stream, BytesCodec::new()).split();
|
||||
sink = Some(Sink::TcpStream(a));
|
||||
while let Ok(Some(Ok(bytes))) = timeout(30_000, b.next()).await {
|
||||
sink = Some(Sink::Tss(SafeTcpStreamSink {
|
||||
sink: a,
|
||||
encrypt: None,
|
||||
}));
|
||||
// Avoid key exchange if answering on nat helper port
|
||||
if !key.is_empty() {
|
||||
self.key_exchange_phase1(addr, &mut sink).await;
|
||||
}
|
||||
while let Ok(Some(Ok(mut bytes))) = timeout(30_000, b.next()).await {
|
||||
// log::debug!("receive tcp data from {:?} {:?}", addr, bytes);
|
||||
if let Some(Sink::Tss(s)) = sink.as_mut() {
|
||||
if let Some(key) = s.encrypt.as_mut() {
|
||||
if let Err(err) = key.dec(&mut bytes) {
|
||||
log::error!("dec tcp data from {:?} err: {:?}", addr, err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !self.handle_tcp(&bytes, &mut sink, addr, key, ws).await {
|
||||
break;
|
||||
}
|
||||
@@ -1225,6 +1476,31 @@ impl RendezvousServer {
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
async fn key_exchange_phase1(&mut self, addr: SocketAddr, sink: &mut Option<Sink>) {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
log::debug!("KeyExchange phase 1: send our pk for this tcp connection in a message signed with our server key");
|
||||
let sk = &self.inner.sk;
|
||||
match sk {
|
||||
Some(sk) => {
|
||||
let our_pk_b = self.inner.secure_tcp_pk_b.clone();
|
||||
let sm = sign::sign(&our_pk_b.0, &sk);
|
||||
|
||||
let bytes_sm = Bytes::from(sm);
|
||||
msg_out.set_key_exchange(KeyExchange {
|
||||
keys: vec![bytes_sm],
|
||||
..Default::default()
|
||||
});
|
||||
log::trace!(
|
||||
"KeyExchange {:?} -> bytes: {:?}",
|
||||
addr,
|
||||
hex::encode(Bytes::from(msg_out.write_to_bytes().unwrap()))
|
||||
);
|
||||
Self::send_to_sink(sink, msg_out).await;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn check_relay_servers(rs0: Arc<RelayServers>, tx: Sender) {
|
||||
@@ -1324,3 +1600,22 @@ async fn create_tcp_listener(port: i32) -> ResultType<TcpListener> {
|
||||
log::debug!("listen on tcp {:?}", s.local_addr());
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
fn get_symetric_key_from_msg(
|
||||
our_sk_b: [u8; 32],
|
||||
their_pk_b: [u8; 32],
|
||||
sealed_value: &[u8; 48],
|
||||
) -> [u8; 32] {
|
||||
let their_pk_b = box_::PublicKey(their_pk_b);
|
||||
let nonce = box_::Nonce([0u8; box_::NONCEBYTES]);
|
||||
let sk = box_::SecretKey(our_sk_b);
|
||||
let key = box_::open(sealed_value, &nonce, &their_pk_b, &sk);
|
||||
match key {
|
||||
Ok(key) => {
|
||||
let mut key_array = [0u8; 32];
|
||||
key_array.copy_from_slice(&key);
|
||||
key_array
|
||||
}
|
||||
Err(e) => panic!("Error while opening the seal key{:?}", e),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
use hbb_common::tokio;
|
||||
use hbbs::jwt;
|
||||
|
||||
#[test]
|
||||
fn test_generate_token() {
|
||||
std::env::set_var("RUSTDESK_API_JWT_KEY", "testjwt");
|
||||
let token = jwt::generate_token(1, 3600).unwrap();
|
||||
println!("Generated Token: {}", token);
|
||||
assert!(!token.is_empty(), "Generated token should not be empty");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_verify_token() {
|
||||
std::env::set_var("RUSTDESK_API_JWT_KEY", "testjwt");
|
||||
let token = jwt::generate_token(1, 2).unwrap();
|
||||
// let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE3MzY4NzA4NjF9.u5pxmwNMrYUwtkspF1FuZj-R5ANAR9WT9_dMHuQhV0Y";
|
||||
println!("Token : {:?}, now: {:?}", token, chrono::Utc::now().timestamp());
|
||||
|
||||
// hbb_common::sleep(3f32).await;
|
||||
// println!("Token : {:?}, now: {:?}", token, chrono::Utc::now().timestamp());
|
||||
let result = jwt::verify_token(&token);
|
||||
println!("Token Verification Result: {:?}", result);
|
||||
assert!(result.is_ok(), "Token should be valid");
|
||||
}
|
||||
Reference in New Issue
Block a user