Debian Codegraph @

README.turnserver

raw
1 GENERAL INFORMATION
2
3 The TURN Server project contains the source code of a TURN server and TURN client
4 messaging library. Also, some extra programs provided, for testing-only
5 purposes.
6
7 See the docs/Build.md file for the building instructions.
8
9 After the build, you will have the following binary images:
10
11 1. turnserver: TURN Server relay.
12 The compiled binary image of the TURN Server program is located in bin/ sub-directory.
13
14 2. turnadmin: TURN administration tool. See README.turnadmin and turnadmin man page.
15
16 3. turnutils_uclient. See README.turnutils and turnutils man page.
17
18 4. turnutils_peer. See README.turnutils and turnutils man page.
19
20 5. turnutils_stunclient. See README.turnutils and turnutils man page.
21
22 6. turnutils_rfc5769check. See README.turnutils and turnutils man page.
23
24 In the "examples/scripts" sub-directory, you will find the examples of command lines to be used
25 to run the programs. The scripts are meant to be run from examples/ sub-directory, for example:
26
27 $ cd examples
28 $ ./scripts/secure_relay.sh
29
30 SYSTEMD
31
32 If the systemd development library is available, then it will notify systemd about the server status.
33
34 RUNNING THE TURN SERVER
35
36 To run the coturn server as a daemon use:
37
38 $ turnserver -o
39
40 Note that if you make any changes to the config file the server has to be restarted.
41
42 Options note: turnserver has long and short option names, for most options.
43 Some options have only long form, some options have only short form. Their syntax
44 somewhat different, if an argument is required:
45
46 The short form must be used as this (for example):
47
48 $ turnserver -L 12.34.56.78
49
50 The long form equivalent must use the "=" character:
51
52 $ turnserver --listening-ip=12.34.56.78
53
54 If this is a flag option (no argument required) then their usage are the same, for example:
55
56 $ turnserver -a
57
58 is equivalent to:
59
60 $ turnserver --lt-cred-mech
61
62 =====================================
63
64 NAME
65
66 turnserver - a TURN relay server implementation.
67
68 SYNOPSIS
69
70 $ turnserver [-n | -c <config-file> ] [flags] [ --userdb=<userdb-file> | --psql-userdb=<db-conn-string> | --mysql-userdb=<db-conn-string> | --mongo-userdb=<db-conn-string> | --redis-userdb=<db-conn-string> ] [-z | --no-auth | -a | --lt-cred-mech ] [options]
71 $ turnserver -h
72
73 DESCRIPTION
74
75 Config file settings:
76
77 -n Do not use configuration file, use only command line parameters.
78
79 -c Configuration file name (default - turnserver.conf).
80 The format of config file can be seen in
81 the supplied examples/etc/turnserver.conf example file. Long
82 names of the options are used as the configuration
83 items names in the file. If not an absolute path is supplied,
84 then the file is searched in the following directories:
85 * current directory
86 * current directory etc/ sub-directory
87 * upper directory level etc/
88 * /etc/
89 * /usr/local/etc/
90 * installation directory /etc
91
92 User database settings:
93
94 -b, --db, --userdb SQLite user database file name (default - /var/db/turndb or
95 /usr/local/var/db/turndb or /var/lib/turn/turndb).
96
97 -e, --psql-userdb, --sql-userdb User database connection string for PostgreSQL.
98 This database can be used for long-term credentials mechanism,
99 and it can store the secret value
100 for secret-based timed authentication in TURN REST API.
101 The connection string format is like that:
102
103 "host=<host> dbname=<dbname> user=<db-user> password=<db-user-password> connect_timeout=<seconds>"
104 (for 8.x or newer Postgres).
105
106 Or:
107
108 "postgresql://username:password@hostname:port/databasename"
109 (for 9.x or newer Postgres).
110
111 See the docs/PostgreSQL.md file for more explanations and examples.
112
113 Also, see http://www.PostgreSQL.org for full PostgreSQL documentation.
114
115 -M, --mysql-userdb User database connection string for MySQL or MariaDB.
116 This database can be used for long-term credentials mechanism,
117 and it can store the secret value for
118 secret-based timed authentication in TURN REST API.
119 The connection string format is like that:
120
121 "host=<host> dbname=<dbname> user=<db-user> password=<db-user-password> connect_timeout=<seconds> read_timeout=<seconds>"
122
123 See the docs/MySQL.md file for more explanations and examples.
124
125 Also, see http://www.mysql.org or http://mariadb.org
126 for full MySQL documentation.
127
128 Optional connection string parameters for the secure communications (SSL):
129 ca, capath, cert, key, cipher
130 (see http://dev.mysql.com/doc/refman/5.1/en/ssl-options.html for the
131 command options description).
132
133 --secret-key-file This is the file path which contain secret key of aes encryption while using MySQL password encryption.
134 If you want to use in the MySQL connection string the password in encrypted format,
135 then set in this option the file path of the secret key. The key which is used to encrypt MySQL password.
136 Warning: If this option is set, then MySQL password must be set in "mysql-userdb" option in encrypted format!
137 If you want to use cleartext password then do not set this option!
138 -J, --mongo-userdb User database connection string for MongoDB.
139 This database can be used for long-term credentials mechanism,
140 and it can store the secret value
141 for secret-based timed authentication in TURN REST API.
142 The connection string format is like that:
143
144 "mongodb://username:password@host:port/database?options"
145
146 See the docs/Mongo.md file for more explanations and examples.
147
148 Also, see http://docs.mongodb.org/manual/
149 for full MongoDB documentation.
150
151 -N, --redis-userdb User database connection string for Redis.
152 This database can be used for long-term credentials mechanism,
153 and it can store the secret
154 value for secret-based timed authentication in TURN REST API.
155 The connection string format is like that:
156
157 "ip=<ip-addr> dbname=<db-number> password=<db-password> connect_timeout=<seconds>"
158
159 See the docs/Redis.md file for more explanations and examples.
160
161 Also, see http://redis.io for full Redis documentation.
162
163 Flags:
164
165 -v, --verbose Moderate verbose mode.
166
167 -V, --Verbose Extra verbose mode, very annoying and not recommended.
168
169 --log-min-level <level> Only emit log messages at or above this level.
170 Valid levels, from most to least verbose:
171 debug = everything (the default)
172 info = informational messages and above
173 warning = warnings and errors only
174 error = errors only
175 An unrecognized level is ignored with a warning.
176
177 -o, --daemon Run server as daemon.
178
179 --no-software-attribute DEPRECATED. See "--software-attribute".
180
181 --software-attribute Send SOFTWARE_ATTRIBUTE on messages that can have it. Disabled by default.
182 Equals to deprecated option "--no-software-attribute false".
183
184 -f, --fingerprint Use fingerprints in the TURN messages. If an incoming request
185 contains a fingerprint, then TURN server will always add
186 fingerprints to the messages in this session, regardless of the
187 per-server setting.
188
189 --include-reason-string Include descriptive reason strings in STUN/TURN error responses.
190 By default, only the standard reason phrase for the error code is
191 sent. Enabling this option adds detailed error descriptions which
192 may aid debugging but can also leak internal server information.
193
194 -a, --lt-cred-mech Use long-term credentials mechanism (this one you need for WebRTC usage).
195
196 -z, --no-auth Do not use any credentials mechanism, allow anonymous access.
197 Opposite to -a and -A options. This is default option when no
198 authentication-related options are set.
199 By default, no credential mechanism is used -
200 any user is allowed.
201
202 --use-auth-secret TURN REST API flag.
203 Flag that sets a special WebRTC authorization option
204 that is based upon authentication secret. The feature purpose
205 is to support "TURN Server REST API" as described in
206 the TURN REST API section below.
207 This option uses timestamp as part of combined username:
208 usercombo -> "timestamp:username",
209 turn user -> usercombo,
210 turn password -> base64(hmac(input_buffer = usercombo, key = shared-secret)).
211 This allows TURN credentials to be accounted for a specific user id.
212 If you don't have a suitable id, the timestamp alone can be used.
213 This option is just turns on secret-based authentication.
214 The actual value of the secret is defined either by option static-auth-secret,
215 or can be found in the turn_secret table in the database.
216
217 --oauth Support oAuth authentication, as in the third-party STUN/TURN RFC 7635.
218
219 --dh566 Use 566 bits predefined DH TLS key. Default size of the key is 2066.
220
221 --dh1066 Use 1066 bits predefined DH TLS key. Default size of the key is 2066.
222
223 --tlsv1 Set TLSv1 as a minimum supported protocol version.
224
225 --tlsv1_1 Set TLSv1.1 as a minimum supported protocol version.
226
227 --no-tlsv1_2 Set TLSv1.3/DTLSv1.2 as a minimum supported protocol version.
228
229 --no-udp Do not start UDP client listeners.
230
231 --no-tcp Do not start TCP client listeners.
232
233 --no-tls Do not start TLS client listeners.
234
235 --no-dtls Do not start DTLS client listeners.
236
237 --no-udp-relay Do not allow UDP relay endpoints defined in RFC 5766,
238 use only TCP relay endpoints as defined in RFC 6062.
239
240 --no-tcp-relay Do not allow TCP relay endpoints defined in RFC 6062,
241 use only UDP relay endpoints as defined in RFC 5766.
242
243 --no-stdout-log Flag to prevent stdout log messages.
244 By default, all log messages are going to both stdout and to
245 the configured log file. With this option everything will be going to
246 the log file only (unless the log file itself is stdout).
247
248 --syslog With this flag, all log will be redirected to the system log (syslog).
249
250 --syslog-facility <value> Set syslog facility for syslog messages. Default is ''.
251
252 --simple-log This flag means that no log file rollover will be used, and the log file
253 name will be constructed as-is, without PID and date appendage.
254 This option can be used, for example, together with the logrotate tool.
255
256 --new-log-timestamp Enable full ISO-8601 timestamp in all logs.
257
258 --new-log-timestamp-format <format> Set timestamp format (in strftime(1) format)
259
260 --log-binding Log STUN binding request. It is now disabled by default to avoid DoS attacks.
261
262 --secure-stun Require authentication of the STUN Binding request.
263 By default, the clients are allowed anonymous access to the STUN Binding functionality.
264
265 -S, --stun-only Run as STUN server only, all TURN requests will be ignored.
266 Option to suppress TURN functionality, only STUN requests will be processed.
267
268 --no-stun Run as TURN server only, all STUN requests will be ignored.
269 Option to suppress STUN functionality, only TURN requests will be processed.
270
271 --allow-loopback-peers Allow peers on the loopback addresses (127.x.x.x and ::1).
272 Allow it only for testing in a development environment!
273 In production it adds a possible security vulnerability,
274 and so due to security reasons, it is not allowed
275 using it together with empty cli-password.
276
277 --no-multicast-peers Disallow peers on well-known broadcast addresses
278 (224.0.0.0 and above, and FFXX:*).
279
280 --mobility Mobility with ICE (MICE) specs support.
281
282 --cli Turn ON the CLI support. By default it is always OFF.
283 See also options --cli-ip and --cli-port.
284
285 --no-cli Turn OFF the CLI support. Since the CLI is OFF by default,
286 this flag is only useful to override a "cli" setting from
287 the configuration file.
288
289 --server-relay Server relay. NON-STANDARD AND DANGEROUS OPTION.
290 Only for those applications when we want to run
291 server applications on the relay endpoints.
292 This option eliminates the IP permissions check
293 on the packets incoming to the relay endpoints.
294 See http://tools.ietf.org/search/rfc5766#section-17.2.3 .
295
296 --udp-self-balance (recommended for older Linuxes only)
297 Automatically balance UDP traffic over auxiliary servers
298 (if configured). The load balancing is using the
299 ALTERNATE-SERVER mechanism. The TURN client must support
300 300 ALTERNATE-SERVER response for this functionality.
301
302 --check-origin-consistency The flag that sets the origin consistency
303 check: across the session, all requests must have the same
304 main ORIGIN attribute value (if the ORIGIN was
305 initially used by the session).
306
307 --drop-invalid-packets Drop invalid packets early. Enabled by default.
308
309 --drop-invalid-packets-log Log invalid packets. The default behaviour is to not log invalid packets.
310
311 --udp-recvmmsg Enable Linux-only batched UDP receive via recvmmsg() on UDP sockets.
312 Auto-enabled when --multiplex-peer is set; pass --udp-recvmmsg=0
313 to override.
314
315 --udp-recvmmsg-log Log Linux recvmmsg batch occupancy stats every 10 seconds.
316
317 --udp-gso Enable Linux UDP-GSO (UDP_SEGMENT cmsg) on the relay send path.
318 When a sendmmsg batch shares destination and segment size, one
319 network-stack traversal carries N datagrams. Requires
320 --multiplex-peer (which is what enables the sendmmsg batching
321 GSO piggybacks on); passing --udp-gso alone is a silent no-op.
322
323 --multiplex-peer Enable peer-side multiplexing relay mode (non-standard,
324 optional). Replaces the per-allocation relay-port bind with a
325 pair of shared UDP sockets per relay thread (one IPv4, one
326 IPv6) covering all TURN sessions on that thread; sessions are
327 demultiplexed by exact peer IP:port lookup. Lifts the
328 ~16 k allocation cap imposed by the relay port range and
329 cuts kernel-side UDP rcvbuf drops dramatically. Implies
330 sendmmsg batching on Linux and default-enables --udp-recvmmsg
331 (explicit --udp-recvmmsg=0 is honoured). Note: EVEN-PORT
332 allocate requests are rejected with 400 in this mode; clients
333 that need EVEN-PORT must use the legacy path. See
334 docs/multiplex-peer.md for design and trade-offs.
335
336 --multiplex-peer-port <port> Base UDP port for multiplex-peer relay sockets
337 (default: 3480). Thread i binds <base>+2i (IPv4) and <base>+2i+1
338 (IPv6); a 4-thread server consumes ports <base>..<base>+7.
339
340 --respond-http-unsupported Return an HTTP response with a 400 status code to HTTP
341 connections made to ports not supporting HTTP. The default
342 behaviour is to immediately close the connection.
343
344 --prometheus Enable prometheus metrics. By default it is
345 disabled. Would listen on port 9641 under the path /metrics
346 also the path / on this port can be used as a health check.
347 Unavailable on apt installations.
348
349 --prometheus-username-labels Enable labeling prometheus traffic
350 metrics with client usernames. Labeling with client usernames is
351 disabled by default, because this may cause memory leaks when using
352 authentication with ephemeral usernames (e.g. TURN REST API).
353
354 --prometheus-port Prometheus listener port (Default: 9641).
355
356 --prometheus-address <address> Prometheus listening address (Default: any).
357
358 --prometheus-path <path> Prometheus serve path (Default: /metrics).
359
360 --version Print version and exit.
361
362 -h Help.
363
364 Options with values:
365
366 --stale-nonce[=<value>] Use extra security with nonce value having
367 limited lifetime, in seconds (default 600 secs).
368 Set it to 0 for unlimited nonce lifetime.
369
370 --max-allocate-lifetime Set the maximum value for the allocation lifetime.
371 Default to 3600 secs.
372
373 --channel-lifetime Set the lifetime for channel binding, default to 600 secs.
374 This value MUST not be changed for production purposes.
375
376 --permission-lifetime Set the value for the lifetime of the permission.
377 Default to 300 secs.
378 This MUST not be changed for production purposes.
379
380 -d, --listening-device Listener interface device.
381 (NOT RECOMMENDED. Optional functionality, Linux only).
382 The turnserver process must have root privileges to bind the
383 listening endpoint to a device. If turnserver must run as a
384 process without root privileges, then just do not use this setting.
385
386 -L, --listening-ip Listener IP address of relay server.
387 Multiple listeners can be specified, for example:
388 -L ip1 -L ip2 -L ip3
389 If no IP(s) specified, then all IPv4 and
390 IPv6 system IPs will be used for listening.
391 The same ip(s) can be used as both listening and relay ip(s).
392
393 -p, --listening-port TURN listener port for UDP and TCP listeners (Default: 3478).
394 Note: actually, TLS & DTLS sessions can connect to the "plain" TCP & UDP
395 port(s), too - if allowed by configuration.
396
397 --tls-listening-port TURN listener port for TLS and DTLS listeners (Default: 5349).
398 Note: actually, "plain" TCP & UDP sessions can connect to the TLS & DTLS
399 port(s), too - if allowed by configuration. The TURN server
400 "automatically" recognizes the type of traffic. Actually, two listening
401 endpoints (the "plain" one and the "tls" one) are equivalent in terms of
402 functionality; but we keep both endpoints to satisfy the RFC 5766 specs.
403 For secure TCP connections, we currently support SSL version 3 and
404 TLS versions 1.0, 1.1, 1.2.
405 For secure UDP connections, we support DTLS version 1.
406
407 --alt-listening-port Alternative listening port for UDP and TCP listeners;
408 default (or zero) value means "listening port plus one".
409 This is needed for STUN CHANGE_REQUEST - in RFC 5780 sense
410 or in old RFC 3489 sense - for NAT behavior discovery). The TURN Server
411 supports CHANGE_REQUEST only if it is started with more than one
412 listening IP address of the same family (IPv4 or IPv6). The CHANGE_REQUEST
413 is only supported by UDP protocol, other protocols are listening
414 on that endpoint only for "symmetry".
415
416 --alt-tls-listening-port Alternative listening port for TLS and DTLS protocols.
417 Default (or zero) value means "TLS listening port plus one".
418
419 --tcp-proxy-port Support connections from TCP loadbalancer on this port. The loadbalancer
420 should use the binary proxy protocol.
421 (https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt)
422
423 --aux-server Auxiliary STUN/TURN server listening endpoint.
424 Aux servers have almost full TURN and STUN functionality.
425 The (minor) limitations are:
426 1) Auxiliary servers do not have alternative ports and
427 they do not support STUN RFC 5780 functionality (CHANGE REQUEST).
428 2) Auxiliary servers also are never returning ALTERNATIVE-SERVER reply.
429
430 Valid formats are 1.2.3.4:5555 for IPv4 and [1:2::3:4]:5555 for IPv6.
431 There may be multiple aux-server options, each will be used for listening
432 to client requests.
433
434 -i, --relay-device Relay interface device for relay sockets
435 (NOT RECOMMENDED. Optional, Linux only).
436
437 -E, --relay-ip Relay address (the local IP address that
438 will be used to relay the packets to the
439 peer). Multiple relay addresses may be used:
440 -E ip1 -E ip2 -E ip3
441 The same IP(s) can be used as both listening IP(s) and relay IP(s).
442 If no relay IP(s) specified, then the turnserver will apply the
443 default policy: it will decide itself which relay addresses to be
444 used, and it will always be using the client socket IP address as
445 the relay IP address of the TURN session (if the requested relay
446 address family is the same as the family of the client socket).
447
448 -X, --external-ip TURN Server public/private address mapping, if the server is behind NAT.
449 In that situation, if a -X is used in form "-X <ip>" then that ip will be reported
450 as relay IP address of all allocations. This scenario works only in a simple case
451 when one single relay address is be used, and no CHANGE_REQUEST functionality is
452 required. That single relay address must be mapped by NAT to the 'external' IP.
453 The "external-ip" value, if not empty, is returned in XOR-RELAYED-ADDRESS field.
454 For that 'external' IP, NAT must forward ports directly (relayed port 12345
455 must be always mapped to the same 'external' port 12345).
456 In more complex case when more than one IP address is involved,
457 that option must be used several times, each entry must
458 have form "-X <public-ip/private-ip>", to map all involved addresses.
459 CHANGE_REQUEST (RFC5780 or RFC3489) NAT discovery STUN functionality will work
460 correctly, if the addresses are mapped properly, even when the TURN server itself
461 is behind A NAT.
462 By default, this value is empty, and no address mapping is used.
463
464 -m, --relay-threads Number of the relay threads to handle the established connections
465 (in addition to authentication thread and the listener thread).
466 If explicitly set to 0 then application runs relay process in a single thread,
467 in the same thread with the listener process (the authentication thread will
468 still be a separate thread). If not set, then a default optimal algorithm
469 will be employed (OS-dependent). In the older Linux systems
470 (before Linux kernel 3.9), the number of UDP threads is always one threads
471 per network listening endpoint - unless "-m 0" or "-m 1" is set.
472
473 --cpus <number> Override system CPU count detection. Use this number
474 instead of the auto-detected CPU count. Useful in virtualized
475 or containerized environments where the visible CPU count does
476 not match what the cgroup actually allows.
477
478 --min-port Lower bound of the UDP port range for relay
479 endpoints allocation.
480 Default value is 49152, according to RFC 5766.
481
482 --max-port Upper bound of the UDP port range for relay
483 endpoints allocation.
484 Default value is 65535, according to RFC 5766.
485
486 --sock-buf-size Set socket buffer size to a new value (in bytes).
487
488 -u, --user Long-term security mechanism credentials user account,
489 in the column-separated form username:key.
490 Multiple user accounts may be used in the command line.
491 The key is either the user password, or
492 the key is generated
493 by turnadmin command. In the second case,
494 the key must be prepended with 0x symbols.
495 The key is calculated over the user name,
496 the user realm, and the user password.
497 This setting may not be used with TURN REST API.
498
499 -r, --realm The default realm to be used for the users when no explicit
500 origin/realm relationship was found in the database, or if the TURN
501 server is not using any database (just the commands-line settings
502 and the userdb file). Must be used with long-term credentials
503 mechanism or with TURN REST API.
504
505 -C, --rest-api-separator This is the timestamp/username separator symbol
506 (character) in TURN REST API. The default value is :.
507
508 -q, --user-quota Per-user allocations quota: how many concurrent
509 allocations a user can create. This option can also be set
510 through the database, for a particular realm.
511
512 -Q, --total-quota Total allocations quota: global limit on concurrent allocations.
513 This option can also be set through the database, for a particular realm.
514
515 -s, --max-bps Max bytes-per-second bandwidth a TURN session is allowed to handle
516 (input and output network streams are treated separately). Anything above
517 that limit will be dropped or temporary suppressed (within the
518 available buffer limits). This option can also be set through the
519 database, for a particular realm.
520
521 -B, --bps-capacity Maximum server capacity.
522 Total bytes-per-second bandwidth the TURN server is allowed to allocate
523 for the sessions, combined (input and output network streams are treated
524 separately).
525
526 --static-auth-secret Static authentication secret value (a string) for TURN REST API only.
527 If not set, then the turn server will try to use the dynamic value
528 in turn_secret table in user database (if present). The database-stored
529 value can be changed on-the-fly by a separate program, so this is why
530 that other mode is dynamic. Multiple shared secrets can be used
531 (both in the database and in the "static" fashion).
532
533 --no-auth-pings Disable periodic health checks to 'dynamic' auth secret tables.
534
535 --no-dynamic-ip-list Do not use dynamic allowed/denied peer ip list.
536
537 --no-dynamic-realms Do not use dynamic realm assignment and options.
538
539
540 --server-name Server name used for
541 the oAuth authentication purposes.
542 The default value is the realm name.
543
544 --cert Certificate file, PEM format. Same file
545 search rules applied as for the configuration
546 file. If both --no-tls and --no-dtls options
547 are specified, then this parameter is not needed.
548 Default value is turn_server_cert.pem.
549
550 --pkey Private key file, PEM format. Same file
551 search rules applied as for the configuration
552 file. If both --no-tls and --no-dtls options
553 are specified, then this parameter is not needed.
554 Default value is turn_server_pkey.pem.
555
556 --raw-public-keys Raw public keys support.
557 On/off switch for RFC-7250 aka raw public keys.
558 Coturn must be built against openSSL version at least 3.2.1
559
560 --pkey-pwd If the private key file is encrypted, then this password to be used.
561
562 --cipher-list Allowed OpenSSL cipher list for TLS/DTLS connections.
563 Default value is "DEFAULT" for TLS/DTLS versions up to TLSv1.2/DTLSv1.2,
564 and the library default ciphersuites for TLSv1.3.
565
566 --CA-file CA file in OpenSSL format.
567 Forces TURN server to verify the client SSL certificates.
568 By default, no CA is set and no client certificate check is performed.
569
570 --ec-curve-name Curve name for EC ciphers, if supported by OpenSSL
571 library (TLS and DTLS). The default value is prime256v1,
572 if pre-OpenSSL 1.0.2 is used. With OpenSSL 1.0.2+,
573 an optimal curve will be automatically calculated, if not defined
574 by this option.
575
576 --dh-file Use custom DH TLS key, stored in PEM format in the file.
577 Flags --dh566 and --dh1066 are ignored when the DH key is taken from a file.
578
579 -l, --log-file Option to set the full path name of the log file.
580 By default, the turnserver tries to open a log file in
581 /var/log/turnserver, /var/log, /var/tmp, /tmp and . (current)
582 directories (which file open operation succeeds
583 first that file will be used). With this option you can set the
584 definite log file name.
585 The special names are "stdout" and "-" - they will force everything
586 to the stdout. Also, "syslog" name will redirect everything into
587 the system log (syslog), as if the option "--syslog" was set.
588 In the runtime, the logfile can be reset with the SIGHUP signal
589 to the turnserver process.
590
591 --alternate-server Option to set the "redirection" mode. The value of this option
592 will be the address of the alternate server for UDP & TCP service in form of
593 <ip>[:<port>]. The server will send this value in the attribute
594 ALTERNATE-SERVER, with error 300, on ALLOCATE request, to the client.
595 Client will receive only values with the same address family
596 as the client network endpoint address family.
597 See RFC 5389 and RFC 5766 for ALTERNATE-SERVER functionality description.
598 The client must use the obtained value for subsequent TURN communications.
599 If more than one --alternate-server options are provided, then the functionality
600 can be more accurately described as "load-balancing" than a mere "redirection".
601 If the port number is omitted, then the default port
602 number 3478 for the UDP/TCP protocols will be used.
603 Colon (:) characters in IPv6 addresses may conflict with the syntax of
604 the option. To alleviate this conflict, literal IPv6 addresses are enclosed
605 in square brackets in such resource identifiers, for example:
606 [2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 .
607 Multiple alternate servers can be set. They will be used in the
608 round-robin manner. All servers in the pool are considered of equal weight and
609 the load will be distributed equally. For example, if we have 4 alternate servers,
610 then each server will receive 25% of ALLOCATE requests. An alternate TURN server
611 address can be used more than one time with the alternate-server option, so this
612 can emulate "weighting" of the servers.
613
614 --tls-alternate-server Option to set alternative server for TLS & DTLS services in form of
615 <ip>:<port>. If the port number is omitted, then the default port
616 number 5349 for the TLS/DTLS protocols will be used. See the
617 previous option for the functionality description.
618
619 --udp-alternate-server Option to set alternative server for UDP & DTLS services in form of
620 <ip>[:<port>]. If the port number is omitted, then the default port
621 number 3478 for the UDP protocol will be used. This list takes
622 precedence over --alternate-server (and over --udp-self-balance) for
623 UDP and DTLS clients. When it is not set, UDP/DTLS clients keep using
624 --alternate-server / --udp-self-balance / --tls-alternate-server as
625 before. See the --alternate-server option for the functionality
626 description.
627
628 --tcp-alternate-server Option to set alternative server for TCP services in form of
629 <ip>[:<port>]. If the port number is omitted, then the default port
630 number 3478 for the TCP protocol will be used. This list takes
631 precedence over --alternate-server for TCP clients. When it is not set,
632 TCP clients keep using --alternate-server as before. See the
633 --alternate-server option for the functionality description.
634
635 -O, --redis-statsdb Redis status and statistics database connection string, if used (default - empty,
636 no Redis stats DB used). This database keeps allocations status information, and it can
637 be also used for publishing and delivering traffic and allocation event notifications.
638 This database option can be used independently of --redis-userdb option,
639 and actually Redis can be used for status/statistics and SQLite or MySQL or MongoDB or
640 PostgreSQL can be used for the user database.
641 The connection string has the same parameters as redis-userdb connection string.
642
643 --max-allocate-timeout Max time, in seconds, allowed for full allocation establishment.
644 Default is 60 seconds.
645
646 --drain-min-allocations In drain mode (entered on SIGUSR1), shut down once the number of
647 active allocations drops to this value or below.
648 Default is 0 (wait until all allocations are gone).
649
650 --denied-peer-ip=<IPaddr[-IPaddr]>
651
652 --allowed-peer-ip=<IPaddr[-IPaddr]> Options to ban or allow specific ip addresses or ranges
653 of ip addresses. If an ip address is specified as both allowed and denied, then
654 the ip address is considered to be allowed. This is useful when you wish to ban
655 a range of ip addresses, except for a few specific ips within that range.
656 This can be used when you do not want users of the turn server to be able to access
657 machines reachable by the turn server, but would otherwise be unreachable from the
658 internet (e.g. when the turn server is sitting behind a NAT). The 'white" and "black" peer
659 IP ranges can also be dynamically changed in the database.
660 The allowed/denied addresses (white/black lists) rules are very simple:
661 1) If there is no rule for an address, then it is allowed;
662 2) If there is an "allowed" rule that fits the address then it is allowed - no matter what;
663 3) If there is no "allowed" rule that fits the address, and if there is a "denied" rule that
664 fits the address, then it is denied.
665
666 --pidfile File name to store the pid of the process.
667 Default is /var/run/turnserver.pid (if superuser account is used) or
668 /var/tmp/turnserver.pid .
669
670 --acme-redirect <URL> Redirect ACME/RFC8555 (like Let's Encrypt challenge) requests, i.e.
671 HTTP GET requests matching '^/.well-known/acme-challenge/(.*)'
672 to <URL>$1 with $1 == (.*). No validation of <URL> will be done,
673 so make sure you do not forget the trailing slash. If <URL> is an empty
674 string (the default value), no special handling of such requests will be done.
675
676 --proc-user User name to run the process. After the initialization, the turnserver process
677 will make an attempt to change the current user ID to that user.
678
679 --proc-group Group name to run the process. After the initialization, the turnserver process
680 will make an attempt to change the current group ID to that group.
681
682 -K, --keep-address-family Deprecated and will be removed in favor of --allocation-default-address-family!!
683 TURN server allocates address family according TURN
684 Client <=> Server communication address family.
685 !! It breaks RFC6156 section-4.2 (violates default IPv4) !!
686
687 -A --allocation-default-address-family=<ipv4|ipv6|keep> Default is IPv4
688 TURN server allocates address family according TURN client requested address family.
689 If address family not requested explicitly by the client, then it falls back to this default.
690 The standard RFC explicitly define that this default must be IPv4,
691 so use other option values with care!
692
693 --cli-ip Local system IP address to be used for CLI management interface.
694 The turnserver process can be accessed for management with telnet,
695 at this IP address and on the CLI port (see the next parameter).
696 Default value is 127.0.0.1. You can use telnet or putty (in telnet mode)
697 to access the CLI management interface.
698
699 --cli-port CLI management interface listening port. Default is 5766.
700
701 --cli-password CLI access password. Default is empty (no password).
702 For the security reasons, it is recommended to use the encrypted
703 form of the password (see the -P command in the turnadmin
704 utility). The dollar signs in the encrypted form must be escaped.
705
706 --cli-max-output-sessions Maximum number of output sessions in ps CLI command.
707 This value can be changed on-the-fly in CLI. The default value is 256.
708
709 --web-admin Enable Turn Web-admin support. By default it is disabled.
710
711 --web-admin-ip=<IP> Local system IP address to be used for Web-admin server endpoint. Default value is 127.0.0.1.
712
713 --web-admin-port=<port> Web-admin server port. Default is 8080.
714 --web-admin-listen-on-workers Enable for web-admin server to listens on STUN/TURN workers STUN/TURN ports.
715 By default it is disabled for security reasons!
716 (This behavior used to be the default behavior, and was enabled by default.)
717
718 --rfc5780 Enable RFC5780 (NAT behavior discovery).
719 Originally, if there are more than one listener address from the same
720 address family, then by default the NAT behavior discovery feature enabled.
721 This option enables this original behavior, because the NAT behavior discovery
722 adds attributes to response, and this increase the possibility of an amplification attack.
723 Strongly encouraged to use this option to decrease gain factor in STUN binding responses.
724
725 --no-rfc5780 DEPRECATED and now the default behaviour. See --rfc5780.
726
727 --stun-backward-compatibility Enable handling old STUN Binding requests using MAPPED-ADDRESS attribute in binding response (instead of XOR-MAPPED-ADDRESS).
728 --unauthorized-ratelimit Enable per-source rate-limiting of 401 Unauthorized responses on UDP. Mitigates
729 reflection/amplification abuse where attackers spoof a victim's source address to
730 bounce 401 challenges off the server. Off by default; opt in explicitly.
731 --unauthorized-ratelimit-rps=<count> Maximum number of 401 Unauthorized responses to send per source IP per second. Default 10.
732
733 ==================================
734
735 LOAD BALANCE AND PERFORMANCE TUNING
736
737 This topic is covered in the wiki page:
738
739 https://github.com/coturn/coturn/wiki/turn_performance_and_load_balance
740
741 ===================================
742
743 WEBRTC USAGE
744
745 This is a set of notes for the WebRTC users:
746
747 1) WebRTC uses long-term authentication mechanism, so you have to use -a
748 option (or --lt-cred-mech). WebRTC relaying will not work with anonymous
749 access. With -a option, do not forget to set the
750 default realm (-r option). You will also have to set up the user accounts,
751 for that you have a number of options:
752
753 a) command-line options (-u).
754
755 b) a database table (SQLite or PostgreSQL or MySQL or MongoDB). You will have to
756 set keys with turnadmin utility (see docs and wiki for turnadmin).
757 You cannot use open passwords in the database.
758
759 c) Redis key/value pair(s), if Redis is used. You key use either keys or
760 open passwords with Redis; see turndb/testredisdbsetup.sh file.
761
762 d) You also can use the TURN REST API. You will need shared secret(s) set
763 either through the command line option, or through the config file, or through
764 the database table or Redis key/value pairs.
765
766 2) Usually WebRTC uses fingerprinting (-f).
767
768 3) -v option may be nice to see the connected clients.
769
770 4) -X is needed if you are running your TURN server behind a NAT.
771
772 5) --min-port and --max-port may be needed if you want to limit the relay endpoints ports
773 number range.
774
775 ===================================
776
777 TURN REST API
778
779 In WebRTC, the browser obtains the TURN connection information from the web
780 server. This information is a secure information - because it contains the
781 necessary TURN credentials. As these credentials are transmitted over the
782 public networks, we have a potential security breach.
783
784 If we have to transmit a valuable information over the public network,
785 then this information has to have a limited lifetime. Then the guy who
786 obtains this information without permission will be able to perform
787 only limited damage.
788
789 This is how the idea of TURN REST API - time-limited TURN credentials -
790 appeared. This security mechanism is based upon the long-term credentials
791 mechanism. The main idea of the REST API is that the web server provides
792 the credentials to the client, but those credentials can be used only
793 limited time by an application that has to create a TURN server connection.
794
795 The "classic" long-term credentials mechanism (LTCM) is described here:
796
797 http://tools.ietf.org/html/rfc5389#section-10.2
798
799 http://tools.ietf.org/html/rfc5389#section-15.4
800
801 For authentication, each user must know two things: the username and the
802 password. Optionally, the user must supply the ORIGIN value, so that the
803 server can figure out the realm to be used for the user. The nonce and
804 the realm values are supplied by the TURN server. But LTCM is not saying
805 anything about the nature and about the persistence of the username and
806 of the password; and this is used by the REST API.
807
808 In the TURN REST API, there is no persistent passwords for users. A user has
809 just the username. The password is always temporary, and it is generated by
810 the web server on-demand, when the user accesses the WebRTC page. And,
811 actually, a temporary one-time session only, username is provided to the user,
812 too.
813
814 The temporary user is generated as:
815
816 temporary-username="timestamp" + ":" + "username"
817
818 where username is the persistent user name, and the timestamp format is just
819 seconds since 1970 - the same value as time(NULL) function returns.
820
821 The temporary password is obtained as HMAC-SHA1 function over the temporary
822 username, with shared secret as the HMAC key, and then the result is encoded:
823
824 temporary-password = base64_encode(hmac-sha1(shared-secret, temporary-username))
825
826 Both the TURN server and the web server know the same shared secret. How the
827 shared secret is distributed among the involved entities is left to the WebRTC
828 deployment details - this is beyond the scope of the TURN REST API.
829
830 So, a timestamp is used for the temporary password calculation, and this
831 timestamp can be retrieved from the temporary username. This information
832 is valuable, but only temporary, while the timestamp is not expired. Without
833 knowledge of the shared secret, a new temporary password cannot be generated.
834
835 This is all formally described in Justin's Uberti TURN REST API document
836 that can be obtained following the link "TURN REST API" in the TURN Server
837 project's page https://github.com/coturn/coturn/.
838
839 Once the temporary username and password are obtained by the client (browser)
840 application, then the rest is just 'classic" long-term credentials mechanism.
841 For developers, we are going to describe it step-by-step below:
842
843 - a new TURN client sends a request command to the TURN server. Optionally,
844 it adds the ORIGIN field to it.
845 - TURN server sees that this is a new client and the message is not
846 authenticated.
847 - the TURN server generates a random nonce string, and return the
848 error 401 to the client, with nonce and realm included. If the ORIGIN
849 field was present in the client request, it may affect the realm value
850 that the server chooses for the client.
851 - the client sees the 401 error and it extracts two values from
852 the error response: the nonce and the realm.
853 - the client uses username, realm and password to produce a key:
854
855 key = MD5(username ":" realm ":" SASLprep(password))
856 (SASLprep is described here: http://tools.ietf.org/html/rfc4013)
857
858 - the client forms a new request, adds username, realm and nonce to the
859 request. Then, the client calculates and adds the integrity field to
860 the request. This is the trickiest part of the process, and it is
861 described in the end of section 15.4:
862 http://tools.ietf.org/html/rfc5389#section-15.4
863 - the client, optionally, adds the fingerprint field. This may be also
864 a tricky procedure, described in section 15.5 of the same document.
865 WebRTC usually uses fingerprinted TURN messages.
866 - the TURN server receives the request, reads the username.
867 - then the TURN server checks that the nonce and the realm in the request
868 are the valid ones.
869 - then the TURN server calculates the key.
870 - then the TURN server calculates the integrity field.
871 - then the TURN server compares the calculated integrity field with the
872 received one - they must be the same. If the integrity fields differ,
873 then the request is rejected.
874
875 In subsequent communications, the client may go with exactly the same
876 sequence, but for optimization usually the client, having already
877 information about realm and nonce, pre-calculates the integrity string
878 for each request, so that the 401 error response becomes unnecessary.
879 The TURN server may use "--stale-nonce" option for extra security: in
880 some time, the nonce expires and the client will obtain 438 error response
881 with the new nonce, and the client will have to start using the new nonce.
882
883 In subsequent communications, the server and the client will always assume
884 the same password - the original password becomes the session parameter and
885 is never expiring. So the password is not changing while the session is valid
886 and unexpired. So, if the session is properly maintained, it may go forever,
887 even if the user password has been already changed (in the database). The
888 session simply is using the old password. Once the session got disconnected,
889 the client will have to use the new password to re-connect (if the password
890 has been changed).
891
892 An example when a new shared secret is generated every hour by the TURN server
893 box and then supplied to the web server, remotely, is provided in the script
894 examples/scripts/restapi/shared_secret_maintainer.pl .
895
896 A very important thing is that the nonce must be totally random and it must be
897 different for different clients and different sessions.
898
899 ===================================
900
901 DATABASES
902
903 For the user database, the turnserver has the following options:
904
905 1) Users can be set in the command line, with multiple -u or --user options.
906 Obviously, only a few users can be set that way, and their credentials are fixed
907 for the turnserver process lifetime.
908
909 2) Users can be stored in SQLite DB. The default SQLite database file is /var/db/turndb
910 or /usr/local/var/db/turndb or /var/lib/turn/turndb.
911
912 3) Users can be stored in PostgreSQL database, if the turnserver was compiled with PostgreSQL
913 support. Each time turnserver checks user credentials, it reads the database (asynchronously,
914 of course, so that the current flow of packets is not delayed in any way), so any change in the
915 database content is immediately visible by the turnserver. This is the way if you need the
916 best scalability. The schema for the database can be found in schema.sql file.
917 For long-term credentials, you have to set the "keys" for the users; the "keys" are generated
918 by the turnadmin utility. For the key generation, you need username, password and the realm.
919 All users in the database must use the same realm value; if down the road you will decide
920 to change the realm name, then you will have to re-generate all user keys (that can be done
921 in a batch script). See the file turndb/testsqldbsetup.sql as an example.
922
923 4) The same is true for MySQL database. The same schema file is applicable.
924 The same considerations are applicable.
925
926 5) The same is true for the Redis database, but the Redis database has a different schema -
927 it can be found (in the form of explanation) in schema.userdb.redis.
928 Also, in Redis you can store both "keys" and open passwords (for long term credentials) -
929 the "open password" option is less secure but more convenient for low-security environments.
930 See the file turndb/testredisdbsetup.sh as an example.
931
932 6) If a database is used, then users can be divided into multiple independent realms. Each realm
933 can be administered separately, and each realm can have its own set of users and its own
934 performance options (max-bps, user-quota, total-quota).
935
936 7) If you use MongoDB, the database will be setup for you automatically.
937
938 8) Of course, the turnserver can be used in non-secure mode, when users are allowed to establish
939 sessions anonymously. But in most cases (like WebRTC) that will not work.
940
941 For the status and statistics database, there are two choices:
942
943 1) The simplest choice is not to use it. Do not set --redis-statsdb option, and this functionality
944 will be simply ignored.
945
946 2) If you choose to use it, then set the --redis-statsdb option. This may be the same database
947 as in --redis-userdb option, or it may be a different database. You may want to use different
948 database for security or convenience reasons. Also, you can use different database management
949 systems for the user database and for the ststus and statistics database. For example, you can use
950 MySQL as the user database, and you can use redis for the statistics. Or you can use Redis for both.
951
952 So, we have 6 choices for the user management, and 2 choices for the statistics management. These
953 two are totally independent. So, you have overall 6*2=12 ways to handle persistent information,
954 choose any for your convenience.
955
956 You do not have to handle the database information "manually" - the turnadmin program can handle
957 everything for you. For PostgreSQL and MySQL you will just have to create an empty database
958 with schema.sql SQL script. With Redis, you do not have to do even that - just run turnadmin and
959 it will set the users for you (see the turnadmin manuals). If you are using SQLite, then the
960 turnserver or turnadmin will initialize the empty database, for you, when started. The
961 TURN server installation process creates an empty initialized SQLite database in the default
962 location (/var/db/turndb or /usr/local/var/db/turndb or /var/lib/turn/turndb, depending on the system).
963
964 =================================
965
966 ALPN
967
968 The server supports ALPNs "stun.turn" and "stun.nat-discovery", when
969 compiled with OpenSSL 1.0.2 or newer. If the server receives a TLS/DTLS
970 ClientHello message that contains one or both of those ALPNs, then the
971 server chooses the first stun.* label and sends it back (in the ServerHello)
972 in the ALPN extension field. If no stun.* label is found, then the server
973 does not include the ALPN information into the ServerHello.
974
975 =================================
976
977 LIBRARIES
978
979 In the lib/ sub-directory the build process will create TURN client messaging library.
980 In the include/ sub-directory, the necessary include files will be placed.
981 The C++ wrapper for the messaging functionality is located in TurnMsgLib.h header.
982 An example of C++ code can be found in stunclient.c file.
983
984 =================================
985
986 DOCS
987
988 After installation, run the command:
989
990 $ man turnserver
991
992 or in the project root directory:
993
994 $ man -M man turnserver
995
996 to see the man page.
997
998 In the docs/html subdirectory of the original archive tree, you will find the client library
999 reference. After the installation, it will be placed in PREFIX/share/doc/turnserver/html.
1000
1001 =================================
1002
1003 LOGS
1004
1005 When the TURN Server starts, it makes efforts to create a log file turn_<pid>.log
1006 in the following directories:
1007
1008 * /var/log
1009 * /log/
1010 * /var/tmp
1011 * /tmp
1012 * current directory
1013
1014 If all efforts failed (due to the system permission settings) then all
1015 log messages are sent only to the standard output of the process.
1016
1017 This behavior can be controlled by --log-file, --syslog and --no-stdout-log
1018 options.
1019
1020 =================================
1021
1022 HTTPS MANAGEMENT INTERFACE
1023
1024 The turnserver process provides an HTTPS Web access as statistics and basic
1025 management interface. The turnserver listens to incoming HTTPS admin
1026 connections on the same ports as the main TURN/STUN listener. The Web admin
1027 pages are basic and self-explanatory.
1028
1029 To make the HTTPS interface active, the database table admin_user must be
1030 populated with the admin user account(s). An admin user can be a superuser
1031 (if not assigned to a particular realm) or a restricted user (if assigned to
1032 a realm). The restricted admin users can perform only limited actions, within
1033 their corresponding realms.
1034
1035 =================================
1036
1037 TELNET CLI
1038
1039 The turnserver process provides a telnet CLI access as statistics and basic management
1040 interface. By default, the turnserver starts a telnet CLI listener on IP 127.0.0.1 and
1041 port 5766. That can be changed by the command-cline options of the turnserver process
1042 (see --cli-ip and --cli-port options). The full list of telnet CLI commands is provided
1043 in "help" command output in the telnet CLI.
1044
1045 =================================
1046
1047 CLUSTERS
1048
1049 TURN Server can be a part of the cluster installation. But, to support the "even port" functionality
1050 (RTP/RTCP streams pairs) the client requests from a particular IP must be delivered to the same
1051 TURN Server instance, so it requires some networking setup massaging for the cluster. The reason is that
1052 the RTP and RTCP relaying endpoints must be allocated on the same relay IP. It would be possible
1053 to design a scheme with the application-level requests forwarding (and we may do that later) but
1054 it would affect the performance.
1055
1056 =================================
1057
1058 FILES
1059
1060 /etc/turnserver.conf
1061
1062 /var/db/turndb
1063
1064 /usr/local/var/db/turndb
1065
1066 /var/lib/turn/turndb
1067
1068 /usr/local/etc/turnserver.conf
1069
1070 =================================
1071
1072 DIRECTORIES
1073
1074 /usr/local/share/turnserver
1075
1076 /usr/local/share/doc/turnserver
1077
1078 /usr/local/share/examples/turnserver
1079
1080 =================================
1081
1082 STANDARDS
1083
1084 obsolete STUN RFC 3489
1085
1086 new STUN RFC 5389
1087
1088 TURN RFC 5766
1089
1090 TURN-TCP extension RFC 6062
1091
1092 TURN IPv6 extension RFC 6156
1093
1094 STUN/TURN test vectors RFC 5769
1095
1096 STUN NAT behavior discovery RFC 5780
1097
1098 =================================
1099
1100 SEE ALSO
1101
1102 turnadmin, turnutils
1103
1104 ======================================
1105
1106 WEB RESOURCES
1107
1108 project page:
1109
1110 https://github.com/coturn/coturn/
1111
1112 Wiki page:
1113
1114 https://github.com/coturn/coturn/wiki
1115
1116 forum:
1117
1118 https://groups.google.com/forum/?fromgroups=#!forum/turn-server-project-rfc5766-turn-server
1119
1120 ======================================
1121
1122 AUTHORS
1123
1124 See the AUTHORS.md file in the coturn source distribution.