Commit Graph

66 Commits

Author SHA1 Message Date
Michael Jones
98d91a73cf
Improve const correctness in coturn (#1424)
Marking variables as const when they won't be modified after
initialization helps programmers trying to understand a codebase to
manage the cognative load.

This pull request uses a clang-tidy fixit (Hard to automate, since the
code needs to be temporarily compiled as C++ for it to work) to try to
mechanically apply the const keyword to code where the automated tool
can determine that the variable won't be modified.

I then follow this up with a manual improvement pass to
turnutils_uclient, where I address const correctness of local variables,
as well as do some adjustments to loops and scoping to help with
reducing complexity.

Co-authored-by: redraincatching <redraincatching@disroot.org>
Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2025-09-08 21:14:56 -07:00
Michael Jones
9ae1e3b3cb
Add spdx tags to all source files (#1510)
With notable exceptions of:

src/apps/common/win/*
src/apps/relay/telnet.*

The purpose of this change is to add the SPDX tags from
https://spdx.dev/, which is a linux foundation project, to the source
code.

This provides automated code provenance tools, which are used in setting
up software bill of materials reports, an easy time verifying that the
code license is known and no incompatibilities are present in a
codebase.

No copyright date, author, or license changes are made.

Note also that
7e525c8e1c
is the original commit for the ACME code (acme.h and acme.c) which was
then moved to acme.h and acme.c in this commit
d4686750ee
but neither commit indicates what license the ACME code was submitted
as.

https://github.com/coturn/coturn?tab=License-1-ov-file#readme is the
3-clause BSD license, but https://github.com/coturn/coturn/pull/672
documents that the author's intent was for the MIT license. So I've used
the SPDX tag and content of the MIT license for this change.
2025-05-30 11:56:04 +02:00
Michael Jones
c9878469fc
[BREAKING] Remove support for openssl older than 1.1.1 (#1397)
Openssl 1.1.1 is end-of-life in September 2023.
This PR removes support for versions of openssl OLDER than 1.1.1
1.1.1 should still be usable after this change is merged.

I don't see any value in supporting 1.1.1, but didn't see a reason to
purge support for 1.1.1 when there are so few checks for >= 3.0.

Note that this does also remove CI support for Ubuntu 16.04. The
official version of OpenSSL from Ubuntu for this release is listed here:
https://launchpad.net/ubuntu/+source/openssl as 1.0.2g

Since no newer releases of coturn will be backported by Canonical to
Ubuntu 16.04, anyone using Coturn on this operating system will have to
download and compile it themselves. They may build their own version of
OpenSSL if they somehow cannot upgrade to a newer version of Ubuntu.

My position is that these users should prefer to upgrade to a newer
operating system than worry about chasing newer releases of Coturn.

Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2024-12-13 13:06:24 -08:00
Michael Jones
b523616b1f
Use bool, instead of int, for the functions in ns_turn_msg.c (#1553)
And address knockon effects in other files, e.g. adjust if-statements
and other function parameters and return types.
2024-08-23 17:49:14 -07:00
Michael Jones
ad94684b23
Use bool over int for the turnutils_uclient program (#1420)
Converts all of the variables in the uclient program that should be bool
but weren't.

A few other minor adjustments made at the behest of clang-tidy, but this
change does not address all of clang-tidy's complaints.
2024-05-29 20:39:51 -07:00
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
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
Pavel Punsky
d3f0ad3be6
Update openssl API use to non-deprecated version (#1072)
Use version independent APIs for openssl-1.1.0 and above

Tested with turnutils_uclient against a turnserver with TLS and DTLS
modes
2022-11-02 19:36:20 -07:00
Gregor Jasny
83b8ddb744
Check and fix format string for turn_log_func_default (#1064) 2022-10-31 11:07:04 -07:00
Yoshiki Kadoshita
9a9e9671f4
Update to fix duplicate stdout log output (#1054)
Disables default log output to stdout if stdout is set as logfile.

When execute `turnutils_stunclient` , the output will be duplicated as
in the following example.

```
$ ./turnutils_stunclient stun.example.com
0: : IPv4. UDP reflexive addr: 203.0.113.1:10000
0: : IPv4. UDP reflexive addr: 203.0.113.1:10000
```

This is because stdout is set in `set_logfile` and furthermore log
output to stdout is done by default.

In this change, call `set_no_stdout_log` to disable default log output
to stdout when stdout is set as logfile.

This solves the problem of duplicate output to stdout of the same log.
2022-10-29 18:13:39 -07: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
Pavel Punsky
d9e74af75d
Cleanup unused include of header files (#1004)
Using clang-tidy to detect unused header files

Inspired by #855

Test Plan:
- Rebuild all on mac, review no warnings/errors
- Pass builds/docker build - review for no issues
2022-10-05 10:28:40 +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
6d9b75dbef
Fix uclient certificate loading bug (#970)
When using `turnutils_uclient` with `-S` flag (TLS or DTLS) it is not required to load certificates. Only load certificates when corresponding flags are provided

Fixes #376 which prevented using `turnutils_uclient` for testing TLS/DTLS connections

Test plan:
- Run local turnserver with certificates `./bin/turnserver --cert ./bin/public.pem --pkey ./bin/private.key --use-auth-secret  --static-auth-secret=secret --realm=north.gov --allow-loopback-peers --no-cli --verbose`
- Run fixed uclient without TLS/DTLS`./bin/turnutils_uclient -e 127.0.0.1 -X -g -u user -W secret 127.0.0.1` and get success result (just to make sure non-secure still works)
- Run fixed uclient with TLS `./bin/turnutils_uclient -e 127.0.0.1 -X -g -u user -W secret -t -S 127.0.0.1` and get success result
- Run fixed uclient with DTLS `./bin/turnutils_uclient -e 127.0.0.1 -X -g -u user -W secret -S 127.0.0.1` and get success result
- Run unpatched uclient with TLS `./bin/turnutils_uclient -e 127.0.0.1 -X -g -u user -W secret -t -S 127.0.0.1` - error about missing certificate files

Co-authored-by: Pavel Punsky <pavel.punsky@epicgames.com>
2022-09-04 14:56:49 +02:00
NeoCat
6be087581f uclient: Show error on invalid peer options specification 2022-08-05 13:19:18 +09: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
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
Mészáros Mihály
a3b8cd59d1 add Falls Through comment hint to compiler to avoid warning 2018-08-02 12:32:13 +02:00
Mészáros Mihály
e8ec72caba Revert "add hint fallthrough to compiler to avoid warning"
This reverts commit 5772435c73.
2018-08-02 12:12:14 +02:00
Mészáros Mihály
5772435c73 add hint fallthrough to compiler to avoid warning 2018-08-01 15:45:24 +02:00
Oleg Moskalenko
a2c17748af cleaning 2016-08-27 20:18:42 -07:00
Oleg Moskalenko
79aed7d8b7 libreSSL compatibility 2016-08-27 16:49:26 -07:00
Oleg Moskalenko
09cde86772 REST API fixes. 2015-11-29 02:00:17 -08:00
Oleg Moskalenko
51ca693359 SSLv3 support removed 2015-11-15 14:58:45 -08:00
Oleg Moskalenko
bd7937cb45 working on openssl compatibility without SSLv3 2015-10-11 18:51:26 -07:00
Oleg Moskalenko
dbc9dee42b working on multi-tenant server based upon oauth 2015-09-14 00:16:13 -07:00
mom040267
ef552b16f4 working on oauth 2015-04-19 09:25:45 +00:00
mom040267
31b25414b4 working on oauth 2015-04-19 08:14:29 +00:00
mom040267
6dbee00b74 working on new third-party auth draft 2015-04-19 07:37:12 +00:00
mom040267
86f40b4bd9 working on third-party auth 2015-04-19 06:18:28 +00:00
mom040267
676843bf09 retiring --sha256, etc 2015-04-11 07:53:30 +00:00
mom040267
4424b3c92a --sha256, --sha384, --sha512 parameters retired. 2015-04-11 07:26:55 +00:00
mom040267
69653ea259 native SCTP support 2015-03-15 19:48:30 +00:00
mom040267
61239f9aa8 bandwidth limit is 64 bits now 2015-03-02 01:44:29 +00:00
mom040267
caf63a35de sha384 added 2015-02-06 08:17:49 +00:00
mom040267
08f0488255 sha512 added 2015-02-05 07:39:07 +00:00
mom040267
0d7d85da58 SHA-512 added to oauth 2015-02-03 07:38:40 +00:00
mom040267
d5b84163b6 working on even-port. 2015-02-01 07:26:29 +00:00
mom040267
3c40c14f40 working on new dual-allocation implementation 2015-01-31 23:25:45 +00:00
mom040267
24053523b5 show oauth keys 2015-01-23 09:26:57 +00:00
mom040267
237b3baaa7 short-term credentials removed in the TURN server 2015-01-11 06:28:58 +00:00
mom040267
b3098cd71d ssl2 removed 2015-01-10 23:29:08 +00:00
mom040267
2b356c2f16 SSLv2 removal 2015-01-10 09:06:30 +00:00
mom040267
5cd0d33c31 1) working on https; 2) SSLv2 support removed. 2015-01-10 08:25:29 +00:00
mom040267
94c3c57456 DTLS code cleaning 2014-12-12 10:23:18 +00:00
mom040267
65dc483208 tls code cleaning 2014-12-11 08:19:29 +00:00
mom040267
786105a9b4 DTLS v1.2 supported. 2014-12-09 09:29:27 +00:00
mom040267
b25a32f10c sqlite support, draft implementation 2014-11-17 09:38:53 +00:00
mom040267
1ab7628cc1 cosmetics 2014-11-09 10:30:26 +00:00