# iotTurn **Repository Path**: G1024admin/iotTurn ## Basic Information - **Project Name**: iotTurn - **Description**: 商用级 Rust TURN/STUN 服务器 - **Primary Language**: Rust - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 2 - **Created**: 2026-10-08 - **Last Updated**: 2026-11-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README English | [简体中文](README.md) # iotturn A production-grade Rust TURN/STUN server with built-in **P2P hole punching**, **traffic metering & quota control**, and **master/slave clustering**. ## Features - STUN / TURN (RFC 8489 / RFC 8656) over UDP / TCP / TLS / DTLS - IPv4/IPv6 dual-stack with RFC 6156/8656 `REQUESTED-ADDRESS-FAMILY` relay allocation (440 on unsupported family, 443 on peer-family mismatch; `ADDITIONAL-ADDRESS-FAMILY` not yet implemented) - Long-Term Credential authentication (stateless nonce) - Built-in P2P hole punching: candidate pre-collection, parallel probing, sub-300ms link setup, seamless relay fallback - Traffic metering & quotas: per-user traffic accounting, data caps (sessions are cut off when exceeded) and bandwidth limiting (e.g. 3 Mbps, account-level shared token bucket) - Master/slave clustering: one-click setup from the admin console, 1 master + N slaves - **Web Admin Console**: embedded single-page admin UI (dashboard / users / sessions / cluster / audit / settings), Chinese & English - **WebRTC demo page**: `/demo` — open two tabs to place a call through STUN/TURN (forced-relay mode available to verify the relay path) - Admin login protection: 10-minute lockout after 5 consecutive failed attempts; recover with `iotturn admin-passwd` / `admin-unlock` ## Live Demo No deployment needed — try it online: **① WebRTC call demo**: **** - Open the page in **two tabs** (or on two devices): it asks for a **room ID (1-999)** first (so users don't all share one default room) — enter the **same room number** on both ends to pair up; the page shows **your own peer ID** and the **current room members** (WebSocket room signaling, across devices/browsers); - Click **Start camera** → **Call** (Chinese UI:「开启摄像头」→「发起呼叫」) to place a call through STUN/TURN; the page shows the live link type (**P2P direct** / **TURN relay**) and **IPv4/IPv6**; - Set the ICE dropdown to **relay** to force all media through TURN and verify the relay path (live candidate counters for host / srflx / relay). **② Admin console demo**: **** - Admin console: `https://:8000/admin/` (set the admin account in the setup wizard on first deployment, or reset it with `iotturn admin-passwd`); - This is a shared public demo — please don't change settings or passwords. Five consecutive failed logins lock the account for 10 minutes (`iotturn admin-unlock` clears it immediately). **Detailed documentation**: [`doc.md`](doc.md) — the complete feature & architecture write-up (Chinese). ## Quick Start ```bash # Build the admin UI first (its output is embedded into the binary) npm --prefix admin_web install npm --prefix admin_web run build # Build / test cargo build --release cargo test ``` Run the binary and open the printed initialization URL — the built-in wizard sets up the super admin and storage (SQLite / MySQL) and restarts into normal mode: ```bash ./iotturn run --config config/iotturn.toml ``` Single-file deployment: the binary embeds the admin console, the WebRTC demo and the Swagger UI, so copying one file to a server is enough (see [`docs/deployment.md`](docs/deployment.md) for a full from-scratch guide). ## Command Line ```bash iotturn # interactive admin menu (bt-style), or run in foreground when non-interactive iotturn start # run as a daemon (systemd-aware; falls back to built-in daemon) iotturn stop|restart|status iotturn log -f # follow logs iotturn admin-path manage # change the admin panel URL path iotturn admin-domain admin.example.com # bind the panel to a domain iotturn admin-passwd admin 'new-strong-password' # reset a forgotten admin password (also clears lockout; restart to apply) iotturn admin-unlock admin # clear login lockout immediately (no arg: list locked accounts) iotturn run # foreground (for systemd / containers) ``` ## Configuration All options live in a single TOML file; `config/iotturn.toml.example` is fully commented. Note: real configuration files under `config/` are excluded by `.gitignore` because they contain credentials — only `*.example` templates are tracked. Key sections: `[listen]` (ports), `[relay]` (public IP + relay port pool), `[auth]` (realm / users), `[quota]` (metering), `[user_store]` (file / sqlite / memory / mysql), `[admin]` (panel), `[cluster]` (master/slave), `[webhooks]` (event push). ## Testing & Benchmarks ```bash cargo test cargo clippy # Optional performance comparison tooling (see doc.md) cargo run --release --example micro_bench # micro-benchmarks (old vs new implementation) cargo run --release --example relay_bench -- --label dev # end-to-end TURN loopback load test ``` Real-server verification scripts are provided under `scripts/` (`verify_*.py`, Python 3). ## Documentation - **Architecture & implementation** (Chinese): [`doc.md`](doc.md) - **Deployment guide** (Chinese): [`docs/deployment.md`](docs/deployment.md) - **Hardware integration guide** (Chinese): [`docs/hardware-integration.md`](docs/hardware-integration.md) - **Changelog**: [`CHANGELOG.md`](CHANGELOG.md) - **Contributing**: [`CONTRIBUTING.md`](CONTRIBUTING.md) · **Security policy**: [`SECURITY.md`](SECURITY.md) ## License Licensed under the **Apache License 2.0** — see [`LICENSE`](LICENSE). The admin console (`admin_web/`) is derived from [TDesign Vue Next Starter](https://github.com/Tencent/tdesign-vue-next-starter) (MIT License); the original license text is preserved in [`admin_web/LICENSE`](admin_web/LICENSE). Third-party dependencies and their licenses are listed in the Chinese README (`README.md`, section「第三方依赖与代码」). ## Contributing Issues and pull requests are welcome — please read [`CONTRIBUTING.md`](CONTRIBUTING.md) first. For security issues see [`SECURITY.md`](SECURITY.md) (please do not open public issues).