A pure Rust implementation of a forwarding server that takes advantage of the memory and concurrency security provided by Rust, with single-threaded decoding speeds up to 5Gib/s and forwarding latency of less than 35 microseconds(One complete local network send/receive between A and B delay). The project is more focused on the core business , do not need to access the complex configuration project , almost out of the box.
This is a very lightweight implementation, and turn-rs will get your data flowing quickly if you only start the basic functionality, and while it uses pre-allocated memory in many places to cope with bursty performance, it generally performs well (it delivers very high-speed forwarding performance on my Raspberry Pi 4 as well as still performs well in the face of a large number of clients).
If you only need a pure turn server to cope with WebRTC business and require excellent forwarding performance, the current project will satisfy you.
First of all, I remain in awe and respect for coturn, which is a much more mature implementation and has very comprehensive support for a wide range of features.
However, turn-rs is not a simple duplicate implementation, and this project is not a blind “RIIR”. Because turn server is currently the largest use of the scene or WebRTC, for WebRTC business, many features are not too much necessary, so keep it simple and fast is the best choice.
Because turn-rs only focuses on the core business, it removes a lot of features that are almost less commonly used in WebRTC scenarios, resulting in better performance, both in terms of throughput and memory performance.
I don't think turn servers should be concerned about user information, just do their essential work, it's better to leave the hosting and storing of user information to other services, and interacting with databases adds complexity. turn-rs communicates with external services through http hooks, which can be more flexible in deciding how to deal with it based on their own business situation.
Unlike coturn, which provides various transport layer encryption, turn-rs does not provide any transport layer encryption. Currently turn clients that support encryption are relatively rare, and there is minimal benefit to the turn server in providing transport layer encryption, since for WebRTC the transport data is already encrypted.
Some clients currently use local addresses for the turn server to create bindings and permissions under certain NAT types, coturn supports this behaviour. However, turn-rs does not allow this behaviour, any client must use the turn server's transit address to communicate, which provides help for clients to hide their IP addresses.
- features
- usage
- building
- document
- driver - (crates.io) Integration with turn-rs server is easy with rust.
- Prometheus metrics exporter.
- Only long-term credential mechanisms are used.
- Static authentication lists can be used in configuration files.
- Only virtual ports are always allocated and no real system ports are occupied.
- The transport layer supports tcp and udp protocols, and supports binding multiple network cards or interfaces.
- The REST API can be used so that the turn server can proactively notify the external service of events and use external authentication mechanisms, and the external can also proactively control the turn server and manage the session.
- RFC 3489 - "classic" STUN
- RFC 5389 - base "new" STUN specs
- RFC 5769 - test vectors for STUN protocol testing
- RFC 5766 - base TURN specs
- RFC 6062 - TCP relaying TURN extension
- RFC 6156 - IPv6 extension for TURN
- TURN REST API (http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00)
First, Get the compiled binaries from github release.
Start with configuration file:
turn-server --config=/etc/turn-server/config.toml
Please check the example configuration file for details: turn-server.toml
docker pull ghcr.io/mycrl/turn-server
The custom configuration file overrides the /etc/turn-server/config.toml
path inside the image through -v
.
./install-service.sh
This will compile the project and install and start the service.
You need to install the Rust toolchain, if you have already installed it, you can skip it, Install Rust, then get the source code:
git clone https://github.com/mycrl/turn-rs
Compile the entire workspace in release mode:
cd turn-rs
cargo build --release
After the compilation is complete, you can find the binary file in the "target/release"
directory.
hooks
- Enable the HTTP Hooks feature.api
- Enable the HTTP REST API server feature.mimalloc
- Enable the mimalloc memory allocator.prometheus
- Enable prometheus indicator support.
No features are enabled by default and need to be turned on by manual specification.
cargo build --release --features api,hooks,mimalloc,prometheus
LGPL Copyright (c) 2022 Mr.Panda.