Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ client/dist
client/src-tauri
android
web/.env
.env
4 changes: 4 additions & 0 deletions .github/scripts/set-version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const targets = [
["ios/native/Cargo.toml", /^(version\s*=\s*")([^"]*)(")/m, version],
["ios/project.yml", /^(\s*MARKETING_VERSION:\s*")([^"]*)(")/m, base],
["ios/project.yml", /^(\s*AIRHAND_VERSION:\s*")([^"]*)(")/m, version],
// 网页控制台(菜单里显示的版本 = web/src/console.rs 的 CARGO_PKG_VERSION)。它的 Docker 镜像用 --locked 构建,
// Cargo.lock 里记着它自己的版本,要一起改,否则 cargo 要更新 Cargo.lock、构建失败
["web/Cargo.toml", /^(version\s*=\s*")([^"]*)(")/m, version],
["web/Cargo.lock", /^(name = "airhand-web"\r?\nversion = ")([^"]*)(")/m, version],
];

for (const [file, pattern, value] of targets) {
Expand Down
155 changes: 154 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
# airhand-server_V_linux-arm64.tar.gz
# airhand-server_V_windows-x64.zip
# SHA256SUMS.txt
#
# Docker 镜像(linux/amd64 + linux/arm64)推送到这个仓库的 GitHub Container Registry,显示在仓库首页右侧的 Packages 里:
# ghcr.io/<owner>/airhand-server 中转服务器(server/Dockerfile)
# ghcr.io/<owner>/airhand-web 网页控制台(web/Dockerfile)
# 标签:每个版本都打 V(如 0.4.0-rc.1);正式版另外更新 X.Y(如 0.4)和 latest。
# 每个平台在原生机器上编译(不用 QEMU 模拟),先只按摘要推送、不打标签;所有平台都编译成功后,在 Publish 里公开 Release 之前
# 合成多平台镜像、打上标签。用的是 GITHUB_TOKEN,不用另外配置 Secret。
# 包第一次推送后默认是私有的:在仓库首页 Packages → 包 → Package settings → Change visibility 改成 Public(两个包各改一次),
# 别人才能不登录直接 docker pull。
name: Release

on:
Expand Down Expand Up @@ -68,6 +77,7 @@ jobs:
outputs:
version: ${{ steps.meta.outputs.version }}
prerelease: ${{ steps.meta.outputs.prerelease }}
registry: ${{ steps.meta.outputs.registry }}
steps:
- uses: actions/checkout@v6

Expand Down Expand Up @@ -100,13 +110,18 @@ jobs:
echo "::warning::The source still says version $src; this release is built as $version (taken from the tag)"
fi
# 镜像名只能是小写
registry="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT"
echo "registry=$registry" >> "$GITHUB_OUTPUT"
{
echo "### Airhand $version"
echo "- Pre-release: $prerelease"
echo "- Server: \`$AIRHAND_SERVER\`"
echo "- Updates from: \`$AIRHAND_UPDATE_REPO\`"
echo "- Docker images: \`$registry/airhand-server\`, \`$registry/airhand-web\`"
} >> "$GITHUB_STEP_SUMMARY"
# ───────────── 桌面客户端 ─────────────
Expand Down Expand Up @@ -463,25 +478,110 @@ jobs:
path: dist/*
if-no-files-found: error

# ───────────── Docker 镜像 ─────────────

# 每个镜像、每个平台在原生机器上编译,只按摘要推送(不打标签);摘要交给 Publish 合成多平台镜像、打标签(见文件开头)
docker:
name: Docker ${{ matrix.image }} ${{ matrix.arch }}
needs: prepare
strategy:
fail-fast: false
matrix:
image: [server, web]
arch: [amd64, arm64]
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
permissions:
contents: read
packages: write
env:
VERSION: ${{ needs.prepare.outputs.version }}
IMAGE: ${{ needs.prepare.outputs.registry }}/airhand-${{ matrix.image }}
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v6
with:
node-version: 24

# 网页控制台菜单里显示的版本号(web/Cargo.toml),和其它各端一样以 tag 为准
- name: Set version
run: node .github/scripts/set-version.mjs "$VERSION"

- uses: docker/setup-buildx-action@v4

- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

# 构建上下文是仓库根目录,和 docker-compose.yml / web/docker-compose.yml 一样。
# org.opencontainers.image.source 把包关联到这个仓库(从 workflow 推送时 GitHub 也会自动关联)
- name: Build and push
id: build
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.image }}/Dockerfile
platforms: linux/${{ matrix.arch }}
labels: |
org.opencontainers.image.title=airhand-${{ matrix.image }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ env.VERSION }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=MIT
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true

- name: Export digest
env:
DIGEST: ${{ steps.build.outputs.digest }}
run: |
mkdir -p "$RUNNER_TEMP/digest"
echo "$DIGEST" > "$RUNNER_TEMP/digest/${{ matrix.image }}-${{ matrix.arch }}"
echo "$IMAGE@$DIGEST"
# 名字以 docker-digest- 开头:Publish 下载要发布的文件时按这个前缀排除
- uses: actions/upload-artifact@v7
with:
name: docker-digest-${{ matrix.image }}-${{ matrix.arch }}
path: ${{ runner.temp }}/digest/*
if-no-files-found: error

# ───────────── 发布 ─────────────

release:
name: Publish
needs: [prepare, windows, linux, macos, android, ios, server-linux, server-windows]
needs: [prepare, windows, linux, macos, android, ios, server-linux, server-windows, docker]
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
packages: write
env:
VERSION: ${{ needs.prepare.outputs.version }}
PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
REGISTRY: ${{ needs.prepare.outputs.registry }}
TAG: ${{ github.ref_name }}
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
steps:
# 要发布的文件;Docker 镜像的摘要(docker-digest-*)不放进 Release
- uses: actions/download-artifact@v8
with:
path: dist
pattern: "!docker-digest-*"
merge-multiple: true

- uses: actions/download-artifact@v8
with:
path: digests
pattern: docker-digest-*
merge-multiple: true

- name: Checksums
Expand Down Expand Up @@ -518,9 +618,62 @@ jobs:
- **Relay server**: keeps its certificate and database in \`data/\` next to the program; see [Deployment](https://github.com/$GH_REPO/blob/$TAG/docs/deploy.md#relay-server). The Linux builds need glibc 2.31+
- Checksums: $(link SHA256SUMS.txt)
## Docker images
linux/amd64 and linux/arm64. Stable releases also update the \`latest\` tag.
| | Image |
|---|---|
| Relay server | \`$REGISTRY/airhand-server:$v\` |
| Web console | \`$REGISTRY/airhand-web:$v\` |
The repository's \`docker-compose.yml\` and \`web/docker-compose.yml\` use these images: upgrade with \`docker compose pull && docker compose up -d\` (back up the relay's \`data/\` first). See [Deployment → Images and upgrades](https://github.com/$GH_REPO/blob/$TAG/docs/deploy.md#images-and-upgrades).
EOF
cat notes.md
- uses: docker/setup-buildx-action@v4

- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

# 把各平台按摘要推送的镜像合成一个多平台镜像、打上标签。在公开 Release 之前做:订阅者收到通知时镜像已经拉得到。
# 多平台镜像的说明和仓库链接要写在 index 的 annotation 里,GHCR 的包页面才显示
- name: Tag Docker images
run: |
base="${VERSION%%-*}" # 0.4.0-rc.1 → 0.4.0
for image in server web; do
repo="$REGISTRY/airhand-$image"
sources=()
for f in digests/"$image"-*; do
[ -f "$f" ] && sources+=("$repo@$(cat "$f")")
done
if [ "${#sources[@]}" -ne 2 ]; then
echo "::error::Expected 2 platform digests for airhand-$image, found ${#sources[@]}"
exit 1
fi
tags=(-t "$repo:$VERSION")
if [ "$PRERELEASE" = false ]; then
tags+=(-t "$repo:${base%.*}" -t "$repo:latest")
fi
case "$image" in
server) desc="Airhand relay server" ;;
web) desc="Airhand web console: the controller in a container, used from a browser" ;;
esac
docker buildx imagetools create "${tags[@]}" \
--annotation "index:org.opencontainers.image.title=airhand-$image" \
--annotation "index:org.opencontainers.image.description=$desc" \
--annotation "index:org.opencontainers.image.source=$GITHUB_SERVER_URL/$GH_REPO" \
--annotation "index:org.opencontainers.image.version=$VERSION" \
--annotation "index:org.opencontainers.image.revision=$GITHUB_SHA" \
--annotation "index:org.opencontainers.image.licenses=MIT" \
"${sources[@]}"
docker buildx imagetools inspect "$repo:$VERSION"
done
# 先建草稿、传完文件再公开,订阅者不会看到缺文件的 Release;重新运行时覆盖已有的文件
- name: Publish
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ client/dist/
client/src-tauri/gen/
*.log
web/.env
# 根目录的 .env:docker-compose.yml 的变量(如固定镜像版本的 AIRHAND_VERSION)
/.env
.DS_Store

# docker compose 挂载的 data 目录:运行时自动生成的证书、私钥、SQLite 数据库等,不要提交
Expand Down
10 changes: 8 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# Airhand 中转服务器
# 启动:docker compose up -d
# 启动:docker compose up -d(拉取发布的镜像;拉不到时从源码构建)
# 查看证书指纹:docker compose logs airhand | grep fingerprint
# 升级:先备份 data/,再 docker compose pull && docker compose up -d
# 从源码构建:docker compose up -d --build
# 固定版本:在本目录的 .env 文件里写 AIRHAND_VERSION=0.4.2(见 docs/deploy.zh-CN.md 的“镜像与升级”)
# Linux 宿主机上先调大 UDP 缓冲区的上限(容器里改不了,见 docs/deploy.zh-CN.md):
# sudo sysctl -w net.core.rmem_max=8388608 net.core.wmem_max=8388608
# 网页控制台(在浏览器里使用的控制端)见 web/docker-compose.yml
services:
airhand:
# 每个版本发布到 GitHub Container Registry 的镜像(linux/amd64、linux/arm64);latest 是最新的正式版。
# 本机没有这个镜像时 docker compose up 先拉取,拉不到才用下面的 build 从源码构建;--build 时总是从源码构建,
# 构建出的镜像也用这个名字(之后 docker compose pull 会换回发布的镜像)
image: ghcr.io/sqlpxc/airhand-server:${AIRHAND_VERSION:-latest}
build:
context: .
dockerfile: server/Dockerfile
image: airhand-server:latest
container_name: airhand-server
restart: unless-stopped
ports:
Expand Down
37 changes: 34 additions & 3 deletions docs/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The server listens on **UDP 4433**. On first start it generates a self-signed ce

Upgrade the clients, web console service and relay together. All use signaling v10 and send video on one QUIC stream per frame. [Frame streams and reference invalidation](architecture.md#frame-streams-and-reference-invalidation)

On its first start a newer server upgrades `airhand.db` to a new format (a table of retired control codes was added); older servers then refuse to open it and won't start. Back up the `data/` directory before upgrading, and restore the backup if you need to go back.
On its first start a newer server upgrades `airhand.db` to a new format (a table of retired control codes was added); older servers then refuse to open it and won't start. Back up the `data/` directory before upgrading, and restore the backup if you need to go back (and pin the old version with `AIRHAND_VERSION`, see [Images and upgrades](#images-and-upgrades)).

Environment variables (see `docker-compose.yml`):

Expand All @@ -25,7 +25,7 @@ Environment variables (see `docker-compose.yml`):
| `AIRHAND_MAX_FILE_SIZE` | `50MiB` | Clipboard file transfer: the most one paste may send through the relay (`512KiB`, `2GiB` or a byte count; `0`: the relay carries no files; `unlimited`: no limit). Doesn't apply while the two ends have a direct path. The server only sees ciphertext and enforces it per stream: it's a resource limit, not a security boundary |
| `RUST_LOG` | `info` | Log level |

The image is based on distroless and is about 28 MB. It runs as root inside the container, so the bind-mounted `data/` is writable whoever owns it (Docker creates it as root if it doesn't exist). On a Linux host with rootful Docker, the files the server creates there belong to root: use `sudo` to read, back up or delete them.
The image (`ghcr.io/sqlpxc/airhand-server`, see [Images and upgrades](#images-and-upgrades)) is based on distroless and is about 28 MB. It runs as root inside the container, so the bind-mounted `data/` is writable whoever owns it (Docker creates it as root if it doesn't exist). On a Linux host with rootful Docker, the files the server creates there belong to root: use `sudo` to read, back up or delete them.

**UDP buffers**: the server sets its socket's send and receive buffers to 8 MiB (the system default is only about 208 KB, which a burst of video at a few tens of Mbps fills up, dropping whole batches of packets: stutter and latency spikes). The Linux kernel silently caps anything above `net.core.rmem_max` / `wmem_max` (this can't be changed from inside the container; set it on the host), and the server logs a warning at startup when that happens:

Expand Down Expand Up @@ -62,6 +62,7 @@ Environment variables (see `web/docker-compose.yml` and `web/.env.example`):
| `AIRHAND_WEB_IDENTITY` | `controller-key.txt` next to `AIRHAND_WEB_CERT` (`/data/controller-key.txt` in the image) | The web console's end-to-end identity (one private key shared by all tabs, file mode 600). Computers paired with the web console recognize it by this key; without a place to keep it the key lives in memory and every restart needs pairing again. End-to-end encryption ends at the web console, so the machine running it can see the picture (see [Security](security.md#end-to-end-encryption)) |
| `AIRHAND_WEB_PASSWORD` | empty | Access password: the browser shows a login prompt, any user name works. Empty means anyone who can reach the port can use the console (connecting to a computer still needs its control code) |
| `AIRHAND_WEB_PORT` | `8080` | Port published on the Docker host |
| `AIRHAND_VERSION` | `latest` | Image version to run (see [Images and upgrades](#images-and-upgrades)) |
| `AIRHAND_WEB_CERT_NAMES` | `localhost` | Names / IPs written into the generated HTTPS certificate (comma-separated). List the address you actually use if you want the OS to trust the certificate |
| `AIRHAND_WEB_CERT` / `AIRHAND_WEB_KEY` | `/data/cert.pem` / `/data/key.pem` | HTTPS certificate paths; to use your own certificate, put it in `web/data/` (or change these paths) |
| `RUST_LOG` | `info` | Log level |
Expand All @@ -71,4 +72,34 @@ Environment variables (see `web/docker-compose.yml` and `web/.env.example`):
- The clipboard is the browser's: text copied on the remote computer is written to this computer's clipboard (while the page is in front); text copied here is sent when you come back to the page, which needs the browser's permission to read the clipboard (Chrome / Edge ask the first time). Firefox doesn't let pages read the clipboard on their own, so there it only syncs from the remote side
- Outside fullscreen the browser keeps some shortcuts (Ctrl+W, Ctrl+T…) for itself; in fullscreen Chrome / Edge lock the keyboard, so the Win key, Alt+Tab and the like go to the remote computer
- Behind a reverse proxy (for your own domain and certificate): proxy to the container's `http://…:8080`, forward WebSockets (`/ws`) and keep the `Host` header (or set `X-Forwarded-Host`), otherwise the WebSocket is rejected as cross-site. A sub-path works too
- The image is based on distroless, runs as root inside the container (like the relay's, so the bind-mounted `web/data/` is writable whoever owns it; with rootful Docker the files in it belong to root on the host), and is about 30 MB. It only needs outbound UDP (to the relay) and this one inbound TCP port
- The image (`ghcr.io/sqlpxc/airhand-web`) is based on distroless, runs as root inside the container (like the relay's, so the bind-mounted `web/data/` is writable whoever owns it; with rootful Docker the files in it belong to root on the host), and is about 30 MB. It only needs outbound UDP (to the relay) and this one inbound TCP port

## Images and upgrades

Every release also publishes the Docker images of the relay server and the web console to the GitHub Container Registry, for linux/amd64 and linux/arm64:

| Image | For |
|---|---|
| `ghcr.io/sqlpxc/airhand-server` | Relay server (`docker-compose.yml`) |
| `ghcr.io/sqlpxc/airhand-web` | Web console (`web/docker-compose.yml`) |

Every release is tagged with its version (`0.4.2`; pre-releases `0.4.2-rc.1`); stable releases also move the minor-version tag (such as `0.4`) and `latest`.

Both Compose files use `latest`, the newest stable release, by default. `docker compose up -d` pulls the image if it isn't on the machine yet, and builds it from source only if the pull fails (for example, when there's no published image for this platform); an image already on the machine is used as is and never updated on its own.

- **Upgrade**:

```bash
docker compose pull # fetch the newest image
docker compose up -d # recreate the container from it; the certificates and database in data/ are kept
```

Back up the relay's `data/` first (a newer server may upgrade the database format, see [Relay server](#relay-server)). Upgrade the clients, web console and relay together
- **Pin a version**: put `AIRHAND_VERSION=0.4.2` in a `.env` file next to the Compose file (the repository root for the relay, `web/.env` for the web console). All `docker compose` commands then use that version, and `docker compose pull` doesn't move past it. To upgrade, change the version and run the two commands above; to go back, change it back to the old version (and, for the relay, restore the `data/` backup from before the upgrade)
- **Build from source** (you changed the code, or want changes that aren't released yet): `docker compose up -d --build`. The built image gets the same name as above, so a later `docker compose pull` replaces it with the published one
- Without Compose, run the image directly, e.g. the relay (pass environment variables with `-e`):

```bash
docker run -d --name airhand-server --restart unless-stopped \
-p 4433:4433/udp -v "$PWD/data:/data" ghcr.io/sqlpxc/airhand-server:latest
```
Loading