turn-rs 1.2.2

A library for handling round sessions.
Documentation
<!--lint disable no-literal-urls-->

<div align="right">
  <a href="./README.CN.md">简体中文</a>
  /
  <a href="./README.md">English</a>
</div>
<div align="center">
  <img src="./logo.svg" width="200px"/>
</div>
<br/>
<div align="center">
  <strong>TURN Server implemented by ❤️ Rust</strong>
</div>
<div align="center">
  <img src="https://img.shields.io/github/actions/workflow/status/mycrl/turn-rs/tests.yml?branch=main"/>
  <img src="https://img.shields.io/github/license/mycrl/turn-rs"/>
  <img src="https://img.shields.io/github/issues/mycrl/turn-rs"/>
  <img src="https://img.shields.io/github/stars/mycrl/turn-rs"/>
</div>
<div align="center">
  <sup>RFC: https://datatracker.ietf.org/doc/html/rfc8656</sup>
</div>
<br/>
<br/>

A turn server implemented pure in rust. Compared with coturn, the advantage is that it provides better performance. It can reach a decoding speed of 5Gib/s in a single thread, and the forwarding delay is less than 35 microseconds. However, it does not provide the same With rich functional support like coturn, this project is most suitable for scenarios where stun/turn servers are used in webrtc.


## Who uses it?


* [`Psyai`]https://psyai.com <sup>(turn-rs has been in service for more than a year without any faults or downtime.)</sup>
* [`Faszialespecialist`]https://faszialespecialist.com/


## Table of contents


* [features]#features
* [usage]#usage
  * [docker]#docker  
  * [linux service]#linux-service
* [building]#building


## Features


- Only long-term authentication mechanisms are supported.
- 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.
- Provides a simple command line tool to manage and monitor the turn server through the command line tool graphical interface. <sup>([`turn-cli`])</sup>
- The GRPC interface 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. <sup>([`proto`])</sup>

[`turn-cli`]: ./cli
[`proto`]: ./protos

## Usage


> The versions on crates.io and docker may be very outdated. It is recommended to compile directly from the github source code.

```bash
cargo install turn-server
```

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 hub
docker pull quasipaa/turn-server
// github packages
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.


## License


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