TURN and STUN 服务器

tyranron 242467faba Update Alpine to 3.22.2 version in Docker image to fix CVE-2025-9230, CVE-2025-9231 and CVE-2025-9232 1 тиждень тому
.github ec5f2bcd83 Upgrade `github/codeql-action` from 3 to 4 version (#1759) 1 тиждень тому
cmake d63704c72d Implement custom prometheus http handler (#1591) 10 місяців тому
docker 242467faba Update Alpine to 3.22.2 version in Docker image to fix CVE-2025-9230, CVE-2025-9231 and CVE-2025-9232 1 тиждень тому
docs ce56a78a7a Add modules diagram to developer doc (#1685) 4 місяців тому
examples 99984fbccd Add configurable CPU count option for containerized environments (#1717) 3 місяців тому
fuzzing da332ed9e7 Add the InsertBraces command for clang-format to ensure that all conditionals always have braces (#1408) 1 рік тому
man 99984fbccd Add configurable CPU count option for containerized environments (#1717) 3 місяців тому
rpm 88fbfa90d5 Fix dead link in turnserver.spec Source0 field (#1722) 3 місяців тому
scripts 678996a529 Update version to 4.7.0 (#1691) 4 місяців тому
src 63447a763a Fix memory leak using libevent (#1751) 2 тижнів тому
turndb a767115055 Add hash algorithm for key value to redis userdb schema 4 роки тому
.clang-format 98d91a73cf Improve const correctness in coturn (#1424) 1 місяць тому
.clang-tidy 98d91a73cf Improve const correctness in coturn (#1424) 1 місяць тому
.dockerignore 8b8660530e Avoid duplication via common rootfs/ dir 4 роки тому
.gitignore 40c99db6ba Support Windows MSVC (#855) 3 роки тому
AUTHORS.md b6e53ca4c9 Update version to 4.6.3 (#1609) 10 місяців тому
CMakeLists.txt 2944775261 Add define to disable OAuth support (#1713) 3 місяців тому
CONTRIBUTING.md 43b430a715 Update CONTRIBUTING.md 2 роки тому
ChangeLog 678996a529 Update version to 4.7.0 (#1691) 4 місяців тому
INSTALL 85c11b69e3 Move and split documentation files (#1096) 2 роки тому
LICENSE 702b29bc22 initial code import 11 роки тому
Makefile.in ce72767375 fixing missing dependencies in Makefile (#1739) 1 місяць тому
README.md d124014428 add fuzzing to ci workflows (#1745) 1 місяць тому
README.turnadmin bc1678cc52 Regenerate manual pages from README files (#1117) 2 роки тому
README.turnserver 14f84fa48c [BREAKING] Deprecate response-origin-only-with-rfc5780 (#1690) 4 місяців тому
README.turnutils da6bc6b0c4 Fix typos (#1345) 1 рік тому
STATUS.md 38088baa22 Update Changelog and Readme (#1087) 2 роки тому
authors.sh 22e51044cd Generate AUTHORS as Markdown, update references (#1102) 2 роки тому
configure 2944775261 Add define to disable OAuth support (#1713) 3 місяців тому
iwyu-ubuntu.imp 72ad1f01d1 Add clang-tidy, include-what-you-use, and msvc-analyzer github actions (#1363) 1 рік тому
make-man.sh 2ff0150c98 man pages util fixed 8 роки тому
postinstall.txt 85c11b69e3 Move and split documentation files (#1096) 2 роки тому
release.sh 678996a529 Update version to 4.7.0 (#1691) 4 місяців тому
vcpkg.json 678996a529 Update version to 4.7.0 (#1691) 4 місяців тому

README.md

Docker CI Docker Hub Fuzzing Status

Docker Hub | GitHub Container Registry | Quay.io

Coturn TURN server

coturn is a free open source implementation of TURN and STUN Server. The TURN Server is a VoIP media traffic NAT traversal server and gateway.

Installing / Getting started

Linux distros may have a version of coturn which you can install by

apt install coturn
turnserver --log-file stdout

Or run coturn using docker container:

docker run -d -p 3478:3478 -p 3478:3478/udp -p 5349:5349 -p 5349:5349/udp -p 49152-65535:49152-65535/udp coturn/coturn

See more details about using docker container Docker Readme

Developing

Dependencies

coturn requires following dependencies to be installed first

  • libevent2

Optional

  • openssl (to support TLS and DTLS, authorized STUN and TURN)
  • libmicrohttp and prometheus-client-c (prometheus interface)
  • MariaDB/MySQL (user database)
  • Hiredis (user database, monitoring)
  • SQLite (user database)
  • PostgreSQL (user database)

Building

git clone [email protected]:coturn/coturn.git
cd coturn
./configure
make

Features

STUN specs:

  • RFC 3489 - "classic" STUN
  • RFC 5389 - base "new" STUN specs
  • RFC 5769 - test vectors for STUN protocol testing
  • RFC 5780 - NAT behavior discovery support
  • RFC 7443 - ALPN support for STUN & TURN
  • RFC 7635 - oAuth third-party TURN/STUN authorization

TURN specs:

ICE and related specs:

The implementation fully supports the following client-to-TURN-server protocols:

Relay protocols:

User databases (for user repository, with passwords or keys, if authentication is required):

  • SQLite
  • MariaDB/MySQL
  • PostgreSQL
  • Redis
  • MongoDB

Management interfaces:

  • telnet cli
  • HTTPS interface

Monitoring:

  • Redis can be used for status and statistics storage and notification
  • prometheus interface (unavailable on apt package)

Message integrity digest algorithms:

  • HMAC-SHA1, with MD5-hashed keys (as required by STUN and TURN standards)

TURN authentication mechanisms:

  • 'classic' long-term credentials mechanism;
  • TURN REST API (a modification of the long-term mechanism, for time-limited secret-based authentication, for WebRTC applications: http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00);
  • experimental third-party oAuth-based client authorization option;

Performance and Load Balancing:

When used as a part of an ICE solution, for VoIP connectivity, this TURN server can handle thousands simultaneous calls per CPU (when TURN protocol is used) or tens of thousands calls when only STUN protocol is used. For virtually unlimited scalability a load balancing scheme can be used. The load balancing can be implemented with the following tools (either one or a combination of them):

  • DNS SRV based load balancing;
  • built-in 300 ALTERNATE-SERVER mechanism (requires 300 response support by the TURN client);
  • network load-balancer server.

Traffic bandwidth limitation and congestion avoidance algorithms implemented.

Target platforms:

  • Linux (Debian, Ubuntu, Mint, CentOS, Fedora, Redhat, Amazon Linux, Arch Linux, OpenSUSE)
  • BSD (FreeBSD, NetBSD, OpenBSD, DragonFlyBSD)
  • Solaris 11
  • Mac OS X
  • Cygwin (for non-production R&D purposes)
  • Windows (native with, e.g., MSVC toolchain)

This project can be successfully used on other *NIX platforms, too, but that is not officially supported.

The implementation is supposed to be simple, easy to install and configure. The project focuses on performance, scalability and simplicity. The aim is to provide an enterprise-grade TURN solution.

To achieve high performance and scalability, the TURN server is implemented with the following features:

  • High-performance industrial-strength Network IO engine libevent2 is used
  • Configurable multi-threading model implemented to allow full usage of available CPU resources (if OS allows multi-threading)
  • Multiple listening and relay addresses can be configured
  • Efficient memory model used
  • The TURN project code can be used in a custom proprietary networking environment. In the TURN server code, an abstract networking API is used. Only couple files in the project have to be re-written to plug-in the TURN server into a proprietary environment. With this project, only implementation for standard UNIX Networking/IO API is provided, but the user can implement any other environment. The TURN server code was originally developed for a high-performance proprietary corporate environment, then adopted for UNIX Networking API
  • The TURN server works as a user space process, without imposing any special requirements on the system

Links