NetMB hbbs signalling-handshake fix (AGPL-3.0)

RustDesk clients with a key and an account token call secure_tcp before sending
their rendezvous request. Upstream OSS hbbs 1.1.16 waits for the request instead,
so both sides wait and the client fails after its handshake deadline.

This patch adds the existing RustDesk transport: a fresh Curve25519 public key
signed with the existing server Ed25519 key, the client's boxed session key,
then secretbox encryption with the upstream framing and sequence counters.
It uses hbb_common::tcp::Encrypt rather than introducing different crypto.
Unsigned clients retain the plain signalling protocol and skip the offer, as
supported by next_rendezvous_msg in the official client. Peer encryption and
permanent-password authentication remain the stock RustDesk implementations.
The API token is not an authorization gate for connecting to peers, matching
OSS behavior; the remote peer still requires its own password/permission.

Upstream: https://github.com/rustdesk/rustdesk-server
Pinned server commit: 73523b31cfd25d77dee862e6fc9f5e1fb5e485ef (1.1.16)
Pinned hbb_common: 83419b6549636ee39dacef7776c473f5802e08d6
Client protocol reference: rustdesk/rustdesk 1.4.9 src/common.rs, src/client.rs.

Build on a Linux Docker host with git and Python 3 installed:
  sh ./build.sh /absolute/path/server-build
Image: netmb-rustdesk-hbbs:1.1.16-netmb.2
Tests cover stock plaintext framing, boxed session-key agreement, encrypted
messages in both directions, invalid exchanges, wrong keys, replay rejection
and oversized frames. One compiler job and a memory limit keep the VPS usable.

Dockerfile.probe builds a separate QA image. Its probe.py validates the actual
wire protocol against an isolated or deployed server, including verification
of the signed server key, two encrypted request/response pairs, plaintext
compatibility and rejection of malformed key exchange. It uses only an absent
test ID; it does not log in or initiate remote access to an existing PC.

Rollback: change only the hbbs image in compose.yml back to
rustdesk/rustdesk-server@sha256:8ecdab65deb7c84652a626380e31d11a8f1fbafd97916d57f95c20628f943c00
and run docker compose up -d --no-deps hbbs. Existing data and keys are reused.

The full corresponding source, including the pinned submodule and this patch,
is published at https://remote.netmb.net/netmb-hbbs-source.tar.gz.

Verified deployment, 2026-10-02:
- Four Rust unit tests passed.
- Isolated Docker server passed all wire-protocol probes.
- Deployed remote.netmb.net:21116 passed the same probes with the original key.
- Actual macOS RustDesk 1.4.9 authenticated to PC-Keller-Werkraum (Windows 1.5.0),
  with "Connection secured", successful peer authentication, H265 video and audio.
- Deployed image ID: sha256:b1c2382db553ebf1b2381b2df37b4949dda3009deaadceb7698f70b6e43274f8

Persistent WSS support (netmb.2)
-------------------------------
websocket-peers.patch and websocket_peers.rs add peer registration on the
WebSocket listener. UDP and WSS share the existing UUID/key checks and database.
A registration mutex retains UDP's serialization for simultaneous WS peers.
Validated WS sessions are indexed by the proxy connection's IP AND source port.
Signals target this channel, not UDP. Heartbeats use the official empty binary
message and keep_alive=30 seconds; disconnects expire only their own current
peer session. A superseded session cannot reclaim or expire a newer connection.
OnlineRequest works over the same WS endpoint. Native and WSS peers interoperate.

Use a reverse proxy with a valid TLS certificate, /ws/id -> 21118 and
/ws/relay -> 21119. Publish both backend ports on loopback only. Overwrite
X-Real-IP and X-Forwarded-For in the proxy. TLS terminates at nginx; end-to-end
peer encryption remains in the official client. The hbbr change below only
fixes pairing, without changing encryption or its wire protocol.

Client >= 1.4: allow-websocket=Y, API https://remote.netmb.net. The default
ID/relay addresses do not change; the client derives the WSS paths from them.
For 1.5.0 also enforce allow-insecure-tls-fallback=N (new setup 1.4.0).
There is no automatic native-to-WebSocket fallback. WSS uses relaying; a
firewall must permit WebSocket upgrades in addition to TCP 443.

Isolated QA (DO NOT run registration tests against the production database):
  docker build -t netmb-hbbs-probe -f Dockerfile.probe .
  # Publish disposable hbbs/hbbr WS endpoints through a test TLS proxy.
  # All IDs and UUIDs in this test are newly generated synthetic fixtures.
  docker run --rm --network host --entrypoint python netmb-hbbs-probe \
    /websocket_probe.py wss://TEST_HOST/ws/id wss://TEST_HOST/ws/relay \
    TEST_TCP_HOST TEST_TCP_PORT TEST_PUBLIC_KEY

Ten isolated protocol checks passed over actual TLS/443 with certificate
validation: registration/status, conflicting UUID, concurrent signals with
signed identity verification, relay negotiation and opaque data both ways,
native controller, heartbeat, reconnect/disconnect, unauthenticated peer
request, concurrent ID claims and malformed/oversized requests. Four previous
Rust crypto/framing unit tests and the native wire probes also passed.

Rollback to the previously tested native-only custom server: restore
/opt/docker/rustdesk/releases/compose-before-wss.yml and
/opt/docker/rustdesk/releases/nginx-before-wss.conf, then recreate hbbs/hbbr
and reload nginx. Clients with WebSocket enabled must first be switched back
to allow-websocket=N; keep the original keys/data directories.

The public archive contains the patched upstream tree and this build directory,
without .git, runtime databases, credentials or executables. To build from it:
  mkdir -p /tmp/netmb-source-build
  tar -xzf netmb-hbbs-source.tar.gz -C /tmp/netmb-source-build
  sh /tmp/netmb-source-build/secure-hbbs/build.sh /tmp/netmb-source-build
A pinned revision marker replaces Git metadata for archive builds. build.sh
creates an empty SQLite compile-time schema from build-schema.sql and passes
DATABASE_URL explicitly to sqlx; runtime peer data are not needed for builds.

Atomic relay pairing
--------------------
relay-pair.patch fixes a reproduced race in OSS hbbr: removing a waiting
socket and inserting the first socket used separate locks. Simultaneous
requests both found an empty slot and one overwrote the other. Both decisions
now use one lock, released before relaying or waiting. Dockerfile.relay builds
netmb-rustdesk-hbbr:1.1.16-netmb.1 from the same pinned upstream source.
websocket_probe.py includes 32 simultaneous pairs, without added sleeps,
and validates bytes in both directions for every pair.
