Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mycrl/turn-rs

A pure rust implemented turn server.
https://github.com/mycrl/turn-rs

p2p rust-lang stun turn webrtc

Last synced: 4 days ago
JSON representation

A pure rust implemented turn server.

Awesome Lists containing this project

README

        







TURN Server implemented by ❤️ Rust










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. The project is more focused on the core business , do not need to access the complex configuration project , almost out of the box .

## Differences with coturn?

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.

##### "Better performance"

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.

##### "Database storage is not supported"

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.

##### "No transport layer encryption"

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.

##### "Only allow turn-rs as transit address"

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.

## Table of contents

- [features](#features)
- [usage](#usage)
- [docker](#docker)
- [linux service](#linux-service)
- [building](#building)
- [document](./docs)
- [install](./docs/install.md)
- [build](./docs/build.md)
- [start the server](./docs/start-the-server.md)
- [configure](./docs/configure.md)
- [rest api](./docs/rest-api.md)
- [http hooks](./docs/http-hooks.md)
- [driver](./drivers) - ([crates.io](https://crates.io/crates/turn-driver)) Integration with turn-rs server is easy with rust.

## Features

- Prometheus metrics exporter.
- Only long-term authentication 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

- [RFC 3489](https://datatracker.ietf.org/doc/html/rfc3489) - "classic" STUN
- [RFC 5389](https://datatracker.ietf.org/doc/html/rfc5389) - base "new" STUN specs
- [RFC 5769](https://datatracker.ietf.org/doc/html/rfc5769) - test vectors for STUN protocol testing
- [RFC 5766](https://datatracker.ietf.org/doc/html/rfc5766) - base TURN specs
- [RFC 6062](https://datatracker.ietf.org/doc/html/rfc6062) - TCP relaying TURN extension
- [RFC 6156](https://datatracker.ietf.org/doc/html/rfc6156) - IPv6 extension for TURN
- TURN REST API (http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00)

## Usage

First, Get the compiled binaries from [github release](https://github.com/mycrl/turn-rs/releases).

Start with configuration file:

```bash
turn-server --config=/etc/turn-server/config.toml
```

Please check the example configuration file for details: [turn-server.toml](./turn-server.toml)

#### Docker

```bash
docker pull ghcr.io/mycrl/turn-server
```

The custom configuration file overrides the `/etc/turn-server/config.toml` path inside the image through `-v`.

#### Linux service

```
./install-service.sh
```

This will compile the project and install and start the service.

## Building

#### Prerequisites

You need to install the Rust toolchain, if you have already installed it, you can skip it, [Install Rust](https://www.rust-lang.org/tools/install), then get the source code:

```bash
git clone https://github.com/mycrl/turn-rs
```

#### Build workspace

Compile the entire workspace in release mode:

```bash
cd turn-rs
cargo build --release
```

After the compilation is complete, you can find the binary file in the `"target/release"` directory.

Prometheus metrics exporter is not enabled by default, use the `prometheus` feature flag if you need to enable it:

```bash
cargo build --release --features prometheus
```

## License

[LGPL](./LICENSE)
Copyright (c) 2022 Mr.Panda.