|
1 |
| -# ExTURN |
| 1 | +# Rel |
2 | 2 |
|
3 |
| -TURN server. |
| 3 | +[](https://github.com/elixir-webrtc/rel/actions/workflows/ci.yml) |
| 4 | +[](https://github.com/elixir-webrtc/rel/actions/workflows/build_deploy.yml) |
| 5 | +[](https://github.com/elixir-webrtc/rel/pkgs/container/rel) |
| 6 | + |
| 7 | +TURN server in pure Elixir. |
| 8 | + |
| 9 | +Aims to implement: |
| 10 | +- [RFC 5766](https://datatracker.ietf.org/doc/html/rfc5766) |
| 11 | +- [RFC 6156](https://datatracker.ietf.org/doc/html/rfc6156#autoid-7) |
| 12 | + |
| 13 | +This project is in early stage of development and some of the features described in the RFCs might be missing. |
| 14 | +Expect breaking changes. |
| 15 | + |
| 16 | +Supports authentication described in [A REST API For Access To TURN Services](https://datatracker.ietf.org/doc/html/draft-uberti-rtcweb-turn-rest-00#section-2.2). |
| 17 | + |
| 18 | +## Public deployment |
| 19 | + |
| 20 | +If you're in need of TURN server for testing purposes, feel free to use this Rel public deployment at `turn.bigcow.ovh`. |
| 21 | + |
| 22 | +In case of any irregularities or bugs, please open an issue with description of the problem. |
| 23 | +DO NOT use this deployment in production, as it's intended to be an aid in developement only. |
| 24 | + |
| 25 | +To obtain a set of credentials, use the built-in credentials mechanism. It does not require any authentication, but the credentials must be refreshed after 3 hours if not used. |
| 26 | + |
| 27 | +```console |
| 28 | +$ curl -X POST "https://turn.bigcow.ovh/?service=turn&username=johnsmith" |
| 29 | +{"password":"l6hs9SzUgudFeb5XjrfCfOWKeOQ=","ttl":1728,"uris":["turn:167.235.241.140:3478?transport=udp"],"username":"1691574817:johnsmith"}⏎ |
| 30 | +``` |
| 31 | + |
| 32 | +Use the obtained credentials in e.g. WebRTC's `RTCPeerConnection`: |
| 33 | + |
| 34 | +```js |
| 35 | +pc = new RTCPeerConnection({ |
| 36 | + iceServers: [ |
| 37 | + { |
| 38 | + credential: "l6hs9SzUgudFeb5XjrfCfOWKeOQ=", |
| 39 | + urls: "turn:167.235.241.140:3478?transport=udp", |
| 40 | + username: "1691574817:johnsmith" |
| 41 | + } |
| 42 | + ] |
| 43 | +}); |
| 44 | +``` |
| 45 | + |
| 46 | +## Installation |
| 47 | + |
| 48 | +1. From source |
| 49 | + |
| 50 | +```console |
| 51 | +git clone https://github.com/elixir-webrtc/rel.git |
| 52 | +cd rel |
| 53 | +mix deps.get |
| 54 | +mix run --no-halt |
| 55 | +``` |
| 56 | + |
| 57 | +2. In Docker |
| 58 | + |
| 59 | +```console |
| 60 | +docker run ghcr.io/webrtc-elixir/rel:latest |
| 61 | +``` |
| 62 | + |
| 63 | +## Features and configuration |
| 64 | + |
| 65 | +Currently, Rel is configured via environment variables. |
| 66 | + |
| 67 | +### TURN server |
| 68 | + |
| 69 | +Rel by default listens on `0.0.0.0:3478/UDP` for TURN traffic. This can be configured via `LISTEN_IP` and `LISTEN_PORT`. |
| 70 | + |
| 71 | +```console |
| 72 | +LISTEN_IP=0.0.0.0 |
| 73 | +LISTEN_PORT=3478 |
| 74 | +``` |
| 75 | + |
| 76 | +`EXTERNAL_LISTEN_IP` is the IP address at which Rel is visible to clients. By default, Rel will try to guess the address |
| 77 | +based on active network interfaces, but this must be set explicitly when e.g. using Docker without `--network host`. |
| 78 | + |
| 79 | +```console |
| 80 | +EXTERNAL_LISTEN_IP=167.235.241.140 |
| 81 | +``` |
| 82 | + |
| 83 | +By default, Rel will use the same addresses (`RELAY_IP == LISTEN_IP and EXTERNAL_RELAY_IP == EXTERNAL_LISTEN_IP`) to open allocations, but this |
| 84 | +can be set to something else: |
| 85 | + |
| 86 | +```console |
| 87 | +RELAY_IP=0.0.0.0 |
| 88 | +EXTERNAL_RELAY_IP=167.235.241.140 |
| 89 | +``` |
| 90 | + |
| 91 | +Remember to use the `DOMAIN_NAME` variable specific to your deployment. It's used in e.g. `SOFTWARE` STUN attributes. |
| 92 | + |
| 93 | +```console |
| 94 | +DOMAIN_NAME=my-amazing-turn.com |
| 95 | +``` |
| 96 | + |
| 97 | +### Auth |
| 98 | + |
| 99 | +Auth Provider is an HTTP endpoint that provides credentials required by *A REST API For Access To TURN Services*. |
| 100 | +By default it is available at `http://127.0.0.1:4000/`, but the address, encryption and CORS can be configured: |
| 101 | + |
| 102 | +```console |
| 103 | +AUTH_PROVIDER_IP=127.0.0.1 |
| 104 | +AUTH_PROVIDER_PORT=4000 |
| 105 | +AUTH_PROVIDER_USE_TLS=false |
| 106 | +KEY_FILE_PAHT=./rel.key |
| 107 | +CERT_FILE_PATH./rel.cert |
| 108 | +AUTH_PROVIDER_ALLOW_CORS=false |
| 109 | +``` |
| 110 | + |
| 111 | +### Metrics |
| 112 | + |
| 113 | +By default, Rel provides Prometheus metrics at `http://127.0.0.1:9578/metrics`. The address can be configured: |
| 114 | + |
| 115 | +```console |
| 116 | +METRICS_IP=127.0.0.1 |
| 117 | +METRICS_PORT=9568 |
| 118 | +``` |
4 | 119 |
|
5 |
| -Implementation of [RFC 5766](https://datatracker.ietf.org/doc/html/rfc5766) and [RFC 6156](https://datatracker.ietf.org/doc/html/rfc6156#autoid-7). |
6 |
| -Supports authentication described in [A REST API For Access to TURN Services](https://datatracker.ietf.org/doc/html/draft-uberti-rtcweb-turn-rest-00). |
|
0 commit comments