A pure Rust implementation of a forwarding server leverages Rust's memory and concurrency safety to process 40 million channel data forwarding messages and 600,000 allocation requests per second within a single thread (excluding network stack overhead). Forwarding latency remains below 35 microseconds (equivalent to a complete local network send/receive delay between points A and B). This project prioritizes core functionality, requiring minimal configuration for use and offering near-out-of-the-box usability.
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.
- 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 GRPC API can be used so that the turn server can proactively notify the external service of events, 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.tomlPlease check the example configuration file for details: turn-server.toml
docker pull ghcr.io/mycrl/turn-serverThe 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-rsCompile the entire workspace in release mode:
cd turn-rs
cargo build --releaseIf you don't need a particular feature, you can reduce the package size by enabling only the features you require.
udp- (enabled by default) Enables UDP transport layer support.tcp- Enables TCP transport layer support.ssl- Enable SSL encryption support.grpc- Enable the GRPC server feature.
All features are enabled by default.
cargo build --releaseAfter the compilation is complete, you can find the binary file in the "target/release" directory.
MIT Copyright (c) 2022 Mr.Panda.