Commit Graph

111 Commits

Author SHA1 Message Date
Michael Jones
da332ed9e7
Add the InsertBraces command for clang-format to ensure that all conditionals always have braces (#1408)
- Why? Because code where conditionals lack braces is much harder to read, and prone to indentation confusion.
- How? Just added an extra flag to .clang-format and re-ran clang-format on all the files.

I also moved .clang-format up to the top level of the repo so that it can be applied to the fuzz targets as well.
2024-01-27 16:38:40 -08:00
Dave Lambley
20c8d86a34
Return a 400 response to HTTP requests (#1231)
For our deployment, it is useful if coturn returns a valid HTTP response to an HTTP request. To do this on the same port as STUN/TURN and without enabling the admin site, I have extended `read_client_connection()` to return a canned HTTP response, in response to an HTTP request, rather than immediately closing the connection.
2023-11-05 17:25:12 -08:00
Pavel Punsky
2850550be1
Fix formatting to fix lint error (#1258) 2023-08-27 16:26:37 -07:00
Cybermilitia
72cf9ba52b
Fix recursive call in delete alternate server (#1250)
I tested the code part by using manual and automated tools for more than
2 years.

Fixes #823 

When you try to delete an alternate server in the list by using "das :" command on the CLI, the session gets stuck and can't response although alternate server is removed.

The problem appears to be related to calling del_alt_server function in the same function recursively.

Co-authored-by: CUMHUR KARAHAN <cumhur.karahan@turkcell.com.tr>
2023-08-13 16:38:19 -07:00
rim
7bc932a905
Fix build with libressl 3.6+ (#1198)
Tested on FreeBSD 13/stable
2023-05-14 16:38:58 -07:00
Emil Ljungdahl
9fa8af6163
Use inline functions for errno checks (#1123)
Since winsock do not use errno, and have different error codes, this is
needed to be windows compatible

This pull request is a split of PR #1061
2022-12-22 11:10:34 -08:00
Pavel Punsky
95373d3e2a
Cleanup logs on turnserver start (#1088)
Reformatting and removing some duplications:
- Some lines have WARNING WARNING: cleaned up.
- Lines printed using perror: only LOG_ mechanism should be used.
- Printing IO mechanism (epoll for example) for each thread: selected
mechanism logged once
- Duplicate lines (perror and also LOG): duplication removed
- Duplicates: clean up (because calling function multiple times -
configuration load)
2022-11-14 17:45:20 -08:00
Gustavo Garcia
d9108a4b54
Add clang format rules and checks (#935)
I would like to get feedback on this and see if people is confortable
with these clang rules.

Right now is using the "llvm" style increasing the line length from 80
to 120 given that coturn is using long lines often.

Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2022-11-06 22:05:17 +01:00
Kang Lin
40c99db6ba
Support Windows MSVC (#855)
The following changes have been made:
1. Replace deprecated functions with new standard functions
2. Add corresponding MSVC functions for non-standard functions 
3. Remove warnings about unsafe functions
4. CMAKE: modify find pack Libevent and openssl 
5. Modify include files
6. Use pthread4W
7. Modify socket in windows
8. Add CI - github action
8.1. msvc
8.2. mingw
10. The database:
9.1. sqlite, pgsql, hiredis, mongo  is test compiled.
9.2. mysql, isnot test compiled.
11. The applications、server can be compiled and run successfully! 
12. Add vcpkg manifest mode in cmake.
2022-10-28 19:32:23 -07:00
Scott Godin
a7316a3d30
created netengine.c get_relay_server utility method to reduce code duplication (#1032) 2022-10-21 20:49:59 +02:00
Pavel Punsky
af9bc12055
Sanitize DB connection string before printing to log (#1020)
Store sanitized version of DB connection string with password masked
(replace all chars with * which exposes its length)
Use sanitized version when logging connection string

Fixes #1017 and #272
2022-10-17 08:44:30 +02:00
Pavel Punsky
3492644c11
Remove debug publish to redis (#1008)
This code is in as back as git can see. Removed for now as it has no use
at all.
Also reduces traffic to redis (though will not reduce any load on redis)

Refs #150
2022-10-06 16:57:44 -07:00
Pavel Punsky
ae2673959b
Use single SSL_CTX for DTLS support (#996)
Similar to #989, use a single SSL context for all versions of DTLS
protocol

- Add support for modern API (protocol version independent APIs)
- Add DTLS test to the CI test
- Removing calls to `SSL_CTX_set_read_ahead` in DTLS context (does
nothing as DTLS is datagram protocol - we always get the whole datagram
so this call has no impact)

Fixes #924
2022-10-05 10:26:46 +02:00
Pavel Punsky
4bab2adba4
Use a single SSL context object (#989)
openssl allows multiple TLS version support through a single SSL_CTX
object.

This PR replaces 4 per-version SSL_CTX objects with a single object
(DTLS is not yet changed).
SSL context initialization code for openssl with modern API (>=1.1.0)
uses `TLS_server_method` and `SSL_CTX_set_min_proto_version` instead of
enabling specific TLS version. Byproduct of this is TLSv1_3 support when
used with openssl-1.1.1 and above

TLS 1.2 and TLS 1.3 cannot be disabled (as before)

Test plan:
- run_tests.sh script now runs turnserver with SSL certificate (which
enables TLS support)
- run_tests.sh now has one more basic test that uses TLS protocol

Co-authored-by: Pavel Punsky <pavel.punsky@epicgames.com>
2022-09-28 09:50:25 +02:00
Pavel Punsky
bd9e44dd7c
Replace bcopy with memcpy (#991)
Replace all instances of `bcopy` with memcpy.

Inspired by https://github.com/coturn/coturn/pull/855
2022-09-20 10:39:11 +02:00
Pavel Punsky
ae259637eb
Replace bzero with memset (#986)
Replace all instances of `bzero` with memset by find-replace-edit.
This is straightforward replacement which is suboptimal in a few cases
(for example we could use calloc instead of malloc+memset(0))

Inspired by #855
2022-09-17 08:36:28 +02:00
Pavel Punsky
9370bb742d
Fix a warning (#988)
There are too many defines that are, eventually, used in one place so
just inlining.

Current code generates following warning:
```
warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
```

With the fix there is no warning

Co-authored-by: Pavel Punsky <pavel.punsky@epicgames.com>
2022-09-17 08:29:32 +02:00
Steffen Moser
02461e9fbc First step to re-enable compilation with OpenSSL 1.0.x 2022-08-23 08:58:45 +02:00
Mark Hills
713bbefd5e Fix a segfault when a TLS context is not used
If the configuration contains entries such as:

  no-tlsv1
  no-tlsv1_1

then the SSL context is NULL. The previous code was simple enough that it
handled this case; the new code needs to deal with it explicitly.

[*] https://github.com/coturn/coturn/issues/770
2021-06-15 23:44:02 +02:00
Mészáros Mihály
708b83ea78 RESPONSE_ORIGIN attribute only if rfc5780 is on 2021-06-05 22:10:31 +02:00
Mészáros Mihály
54ef051844 Disable stun backward compatibility 2021-06-05 22:10:31 +02:00
Mészáros Mihály
eda11698f0 Add option no-rfc5780
To avoid any amplifiaction STUN binding attacks.
2021-06-05 22:10:31 +02:00
Mészáros Mihály
8c9622ad18 Add a check, don't SSL_CTX_up_ref a null pointer
This cause segmentation failure. Regression..
2021-06-05 22:10:31 +02:00
Mark Hills
8f1908d7bd A use-after-free can occur on the SSL_ctx on a busy system
When openssl_load_certificates() is called as a result of USR2
signal, it has the effect of SSL_free() on certificates.

But pointers to these certificates are borrowed by the ioa_engines
where they are used for new connections.

The tls_mutex when loading the certificates does not prevent this use
because it's released before despatching asynchronous events to each
ioa_engine asking them to pick up the new SSL context.

So there is a race; if a new connection arrives quickly after
openssl_load_certificates() but before the tls_ctx_update_ev.

This patch resolves this using OpenSSL's own fine grained locking.
The ioa_engines now 'copy' the SSL context (actually a refcounted copy)
2021-03-23 16:02:06 +00:00
Mészáros Mihály
2204778ce1 Replace keep-address-family with allocation-default-address-family 2021-03-12 23:05:18 +01:00
Mészáros Mihály
104ab83f09 Automatically notify systemd if compiled 2021-01-10 20:57:43 +01:00
Mészáros Mihály
ef7916842d Add systemd notification support 2021-01-07 17:51:34 +00:00
Mészáros Mihály
27b261eb58 Disable binding logging to avoid DoS attack
* Add new option log-binding
2021-01-05 09:55:55 +00:00
Jens Elkner
7e525c8e1c support of --acme-redirect <URL> 2020-12-15 13:01:51 +00:00
Greg Fodor
38e7daf3d6 Merge remote master 2020-04-28 17:18:30 +00:00
Mészáros Mihály
991a82e104
Merge branch 'master' into master 2020-04-28 09:47:20 +02:00
Greg Fodor
52320f8ac9 Add flags to disable periodic use of dynamic tables 2020-04-18 01:27:54 +00:00
Danilo Bargen
520e172b22 Rename "prod" config option to "no-software-attribute"
As discussed in https://github.com/coturn/coturn/pull/478, if the
parameter only controls whether or not to send the software attribute
and not other production-relevant configurations, it should be named
accordingly.

The old --prod configuration option still works, but is now deprecated
and undocumented.
2020-03-13 11:03:05 +01:00
Bertold Van den Bergh
ace903fd07 Add support for loadbalanced TCP connections (haproxy protocol v2) 2020-02-13 01:56:43 +01:00
Bradley T. Hughes
d2ee3ac291 Remove [su]{08,16,32,64}bits type defines
Do not overload the standard types with #defines, just use them
directly.
2019-03-08 09:08:30 +01:00
Bradley T. Hughes
7663167dff Remove pointer debugging machinery
There are tools and debugging options that can be used instead. Do not
reinvent the wheel with our own pointer tracking/debugging code.
2019-03-07 08:39:20 +01:00
Bradley T. Hughes
7a43aae7c3 Remove ns_bzero(), ns_bcopy(), and ns_bcmp()
Do not overload bzero(), bcopy(), and bcmp() from strings.h
2019-03-07 08:39:20 +01:00
Bradley T. Hughes
043b102e38 Remove turn_strdup()
Do not overload strdup() from string.h
2019-03-07 08:00:08 +01:00
Bradley T. Hughes
b50fc77124 Remote turn_free()
Do not overload free() with a different API.
2019-03-07 07:58:12 +01:00
Bradley T. Hughes
31033c3ffa Remote turn_realloc()
Do not overload realloc() with a different API.
2019-03-07 07:57:35 +01:00
Bradley T. Hughes
fef016901e Remove turn_malloc()
Do not overload malloc() from stdlib.h
2019-03-06 23:38:20 +01:00
Mészáros Mihály
23cfaa1253 add --web-admin-listen-on-workers 2018-09-12 10:30:09 +02:00
Thibaut Ackermann
b2fcc81a0d Move web-admin to dedicated (configurable) ip:port 2018-09-12 10:30:09 +02:00
Mészáros Mihály
025dc300ce Revert "Enhancement: Add option to disable Web-Management-Interface"
This reverts commit c48835e230.
2018-09-12 10:30:09 +02:00
Mészáros Mihály
8a60754d70 Change loopback defaults 2018-09-12 10:30:07 +02:00
Mészáros Mihály
93c1103bb8 Add new feature: keep-address-family 2018-09-06 14:26:42 +02:00
shuyin.wsy
0964392b9f Fix: race auth_server thread create & detach 2018-09-05 11:39:00 +02:00
Arne Georg Gisnås Gleditsch
6bc4bab95b Make SIGUSR2 reload TLS certificates
This commit does the following:

* Factor out loading of TLS keys and certificates into turn_params SSL
  context so that it can be repeated. (Contexts are not overwritten
  when loading encounters errors, but initial contexts will be set
  regardless of errors. This keeps existing semantics.)
* Isolate copying of turn_params SSL context to ioa_engine structs
  into callback functions appropriate for libevent invocation.
* Chain both of the above to a signal event handler responding to
  SIGUSR2.

This allows replacement of keys and certificates during run-time
without interrupting relaying operations.
2018-04-19 14:51:07 +02:00
Carsten Bock
c48835e230 Enhancement: Add option to disable Web-Management-Interface 2017-04-10 14:49:55 +02:00
yohan
e241d0c71f Add "--prod" to turnserver command-line options. It will hide turnserver version (like apache does).
This is a common corporate security requirement.
2016-10-27 17:48:32 +02:00