turnserver.1 45 KB

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