1
0
mirror of https://github.com/coturn/coturn.git synced 2025-12-24 17:31:00 +01:00

1822 Commits

Author SHA1 Message Date
tyranron
6a0b3a648a
Update Alpine to 3.23.2 version in Docker image docker/4.7.0-r4 2025-12-18 14:44:24 +01:00
dependabot[bot]
15cecc97a2
Upgrade actions/download-artifact from 6 to 7 version (#1785)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-13 01:44:37 +01:00
dependabot[bot]
60ed2e246e
Upgrade actions/upload-artifact from 5 to 6 version (#1784)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-13 01:43:51 +01:00
dependabot[bot]
b7dfa236c1
Upgrade actions/cache from 4 to 5 version (#1783)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-12 12:03:36 +01:00
tyranron
5a6c9f3ce4
Update Debian "trixie" to 20251208 snapshot in Docker image 2025-12-09 12:33:53 +01:00
Pavel Punsky
265d1029e6
Use bool to enable prometheus (#1779)
`turn_params.prometheus` is bool but used as int throughout the code
`turn_params,prometheus_username_labels` is bool but in one place is set
with 1

This PR changes 0 and 1 to false and true accordingly
2025-12-08 08:43:36 -08:00
tyranron
a668d4b4cc
Upgrade Alpine to 3.23 version in Docker image docker/4.7.0-r3 2025-12-04 15:34:15 +01:00
dependabot[bot]
9298847097
Upgrade actions/checkout from 5 to 6 version (#1776)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-21 13:37:27 +01:00
tyranron
60b6e2d816
Update Debian "trixie" to 20251117 snapshot in Docker image 2025-11-18 13:57:46 +01:00
tyranron
e1d3ba8a69
Update Debian "trixie" to 20251103 snapshot in Docker image 2025-11-05 12:04:30 +02:00
dependabot[bot]
5c14404c71
Upgrade actions/upload-artifact from 4 to 5 version (#1771)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-25 10:03:37 +02:00
dependabot[bot]
7cd09efe87
Upgrade actions/download-artifact from 5 to 6 version (#1772)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-25 10:02:45 +02:00
tyranron
bc8d0ca36b
Update Debian "trixie" to 20251020 snapshot in Docker image 2025-10-22 14:28:29 +03:00
tyranron
242467faba
Update Alpine to 3.22.2 version in Docker image to fix CVE-2025-9230, CVE-2025-9231 and CVE-2025-9232 docker/4.7.0-r2 2025-10-09 14:13:50 +03:00
dependabot[bot]
ec5f2bcd83
Upgrade github/codeql-action from 3 to 4 version (#1759)
Additionally:
- fix missing NSIS for Windows on CI
- replace macOS 13 with 26 on CI

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kai Ren <tyranron@gmail.com>
2025-10-08 13:43:16 +02:00
tyranron
e1ce664cbb
Update Debian "trixie" to 20250929 snapshot in Docker image 2025-09-30 14:27:15 +03:00
Pavel Punsky
63447a763a
Fix memory leak using libevent (#1751)
Fixes #1750
2025-09-28 21:00:44 -07:00
redraincatching
b1dddb5f49
addressed possible null pointer dereferences (#1729)
this pr aims to address more static code analyser warnings, specifically
null pointer dereferences. the majority of changes are solely to quieten
the analyser, as `malloc` and `calloc` are unlikely to fail, but this
should at least lead to the code analysis being more readable and
usable.

where functions addressed had existing failure strategies, they were
used, however some functions will now silently fail rather than
attempting to dereference a null pointer. if there is a preferred
solution in these cases, i will be happy to implement it.

---

-
[27](https://github.com/redraincatching/coturn/security/code-scanning/27):
moved use of pointer inside `else` block of null check
-
[42](https://github.com/redraincatching/coturn/security/code-scanning/42):
added early return in case of null pointer
-
[69](https://github.com/redraincatching/coturn/security/code-scanning/69):
added null pointer check after `malloc`
-
[76](https://github.com/redraincatching/coturn/security/code-scanning/76):
added null pointer check after `calloc`
-
[77](https://github.com/redraincatching/coturn/security/code-scanning/77):
added null pointer check to loop guard
-
[82](https://github.com/redraincatching/coturn/security/code-scanning/82):
added null pointer check after `malloc`
-
[83](https://github.com/redraincatching/coturn/security/code-scanning/83):
added null pointer check after `malloc`
-
[84](https://github.com/redraincatching/coturn/security/code-scanning/84):
added null pointer check after `calloc`
-
[85](https://github.com/redraincatching/coturn/security/code-scanning/85):
added null pointer check around pointer use, as done earlier in the same
function
-
[86](https://github.com/redraincatching/coturn/security/code-scanning/86):
added null pointer check after `calloc`
-
[90](https://github.com/redraincatching/coturn/security/code-scanning/90)/[91](https://github.com/redraincatching/coturn/security/code-scanning/91)/[92](https://github.com/redraincatching/coturn/security/code-scanning/92)/[93](https://github.com/redraincatching/coturn/security/code-scanning/93):
added null pointer check to block
-
[94](https://github.com/redraincatching/coturn/security/code-scanning/94)/[95](https://github.com/redraincatching/coturn/security/code-scanning/95):
added null pointer checks after `malloc`
-
[108](https://github.com/redraincatching/coturn/security/code-scanning/108):
added check after `calloc`
-
[114](https://github.com/redraincatching/coturn/security/code-scanning/114):
added check after `memcpy`
-
[129](https://github.com/redraincatching/coturn/security/code-scanning/129):
added check after `calloc`
-
[145](https://github.com/redraincatching/coturn/security/code-scanning/145):
added check to if guard
-
[146](https://github.com/redraincatching/coturn/security/code-scanning/146):
added check to if guard
-
[154](https://github.com/redraincatching/coturn/security/code-scanning/154):
added early exit with error
-
[165](https://github.com/redraincatching/coturn/security/code-scanning/165):
added check after `malloc`
-
[170](https://github.com/redraincatching/coturn/security/code-scanning/170):
added early null return on null pointer
-
[171](https://github.com/redraincatching/coturn/security/code-scanning/171):
added check after `calloc`

---
![You're dereferencing a null
pointer!](https://i.makeagif.com/media/9-29-2015/YwGqu_.gif)
2025-09-11 18:00:38 -07:00
tyranron
0f46392ec1
Update Debian "trixie" to 20250908 snapshot in Docker image 2025-09-09 11:45:29 +03:00
redraincatching
2a9b77bd0b
address possible null pointer dereferences (#1744)
# addressing all remaining code scanning instances of warning C6011,
null pointer dereference

this pr aims to address more static code analyser warnings, specifically
null pointer dereferences. the majority of changes are solely to quieten
the analyser, as `malloc` and `calloc` are unlikely to fail, but this
should at least lead to the code analysis being more readable and
usable.

where functions addressed had existing failure strategies, they were
used, however some functions will now silently fail rather than
attempting to dereference a null pointer. if there is a preferred
solution in these cases, i will be happy to implement it.

---

this is an extension of [this pull
request](https://github.com/coturn/coturn/pull/1729)
2025-09-08 21:18:33 -07:00
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
Pavel Punsky
0749cd7efd
Update attribute values according to RFC 8656 (#1748)
Source https://datatracker.ietf.org/doc/html/rfc8656#section-18
Now conforms to RFC specification

- ADDITIONAL_ADDRESS_FAMILY (0x8000) - was (0x8032)
- ADDRESS_ERROR_CODE (0x8001) - was (0x8033)

Fixes #1740
2025-09-07 19:34:38 -07:00
Jun Lyu
ce72767375
fixing missing dependencies in Makefile (#1739)
This PR fixes an issue in the Makefile. Specifically, previously, any
modifications of files like src/apps/common/ns_turn_openssl.h would not
trigger a rebuild of build/obj/ns_turn_msg.o. The PR fixes this by
including them as additional dependencies.
2025-09-06 17:46:59 -07:00
redraincatching
d124014428
add fuzzing to ci workflows (#1745)
allow fuzzing to be performed as part of the continuous integration.

the timing of the fuzzing can be extended, and i aim to broaden the
scope of the fuzz testing as well, since we currently only test the stun
message parser.
2025-09-05 10:37:58 -07:00
Lidong Yan
439914716d
mainreplay: fix leak in decrypt_aes_128() (#1737)
In decrypt_aes_128() at src/apps/replay/mainreplay.c, it calls
base64decode() to allocates memory in encryptedText, but forgets to free
encryptedText in the end of this function. Add free() after finished
using encryptedText.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
2025-09-05 10:36:55 -07:00
dependabot[bot]
04a8e52e09
Upgrade actions/github-script from 7 to 8 version (#1746)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-05 14:20:10 +02:00
tyranron
24e99eca1c
Upgrade Debian to "trixie" in Docker image 2025-08-13 15:59:17 +03:00
tyranron
8b55bd05c0
Update Debian "bookworm" to 20250811 snapshot in Docker image 2025-08-13 14:38:44 +03:00
dependabot[bot]
3cfa30552d
Upgrade actions/checkout from 4 to 5 version (#1733)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-12 13:30:02 +02:00
Kai Ren
c67a41f5ff
Upgrade vcpkg to 2025.07.25 release on MSVC CI (#1734) 2025-08-12 12:45:21 +02:00
dependabot[bot]
20761e0cd5
Upgrade actions/download-artifact from 4 to 5 version (#1731)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-06 11:22:45 +02:00
tyranron
3a788061a0
Update Debian "bookworm" to 20250721 snapshot in Docker image 2025-07-22 13:07:58 +03:00
tyranron
4b69110460
Fix typo in Docker CI spec docker/4.7.0-r1 2025-07-16 13:29:08 +03:00
tyranron
f386333d00
Update Alpine to 3.22.1 version in Docker image 2025-07-16 13:27:51 +03:00
tyranron
752cf2e565
Verify CHANGELOG date on Docker CI 2025-07-16 13:25:41 +03:00
Gustavo Garcia
6877e91c20
Fix logging before parsing logging cmd line args (#1723)
When using --log-file stdout to redirect turnserver logs to stdout
instead of creating a log file, a default log file was still being
created. This happened because the --log-file argument was processed
after logging had already occurred during startup.

Fix #1670
2025-07-14 15:44:34 +02:00
Copilot
88fbfa90d5
Fix dead link in turnserver.spec Source0 field (#1722)
The `Source0` field in `rpm/turnserver.spec` was pointing to a dead link
at
`http://turnserver.open-sys.org/downloads/v%{version}/%{name}-%{version}.tar.gz`.
The domain `turnserver.open-sys.org` is no longer resolvable, making RPM
package building impossible when relying on this source.

**Changes made:**
- Updated `Source0` to use GitHub archive URL:
`https://github.com/coturn/coturn/archive/refs/tags/upstream/%{version}.tar.gz`
- Updated version from `4.7.0` to `4.5.2` to match the latest available
GitHub tag (`upstream/4.5.2`)

**Verification:**
-  Old URL confirmed dead (domain resolution fails)
-  New GitHub archive URL works correctly and downloads valid gzipped
tar archive
-  RPM spec file syntax validation passes (`rpmbuild --nobuild`)
-  URL properly expands with RPM variable substitution

The new source URL format follows GitHub's standard archive pattern and
will work reliably for future RPM builds.

Fixes #1574.

> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `turnserver.open-sys.org`
>   - Triggering command: `curl -I REDACTED` (dns block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to my [firewall allow
list](https://gh.io/copilot/firewall-config)
>
> </details>



<!-- START COPILOT CODING AGENT TIPS -->
---

💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to
start the survey.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ggarber <512252+ggarber@users.noreply.github.com>
2025-07-14 12:03:20 +02:00
redraincatching
68ac0772d9
reduce calls to random (#1710)
implemented change suggested in TODO to speed up aes key generation
without, hopefully, negatively impacting the overall randomness of the
function

---------

Co-authored-by: Gustavo Garcia <gustavogb@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-11 12:42:28 +02:00
Gustavo Garcia
4de6c14f71
Fix null pointer dereference in set_ssl_ctx function (#1720)
This PR fixes a null pointer dereference vulnerability where
`set_ssl_ctx()` could crash when passed a NULL engine handle.

## Problem

The `create_ioa_engine()` function can return NULL when invalid
parameters are provided:

```c
if (!relays_number || !relay_addrs || !tp) {
  TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: Cannot create TURN engine\n", __FUNCTION__);
  return NULL;
}
```

However, two calling functions don't check for NULL before passing the
result to `set_ssl_ctx()`:

1. **`setup_relay_server()`** (line 1646):
   ```c
   rs->ioa_eng = create_ioa_engine(...);
set_ssl_ctx(rs->ioa_eng, &turn_params); // Potential NULL dereference
   ```

2. **`create_new_listener_engine()`** (line 955):
   ```c
   ioa_engine_handle e = create_ioa_engine(...);
   set_ssl_ctx(e, &turn_params);  // Potential NULL dereference
   ```

The `set_ssl_ctx()` function then dereferences the engine parameter
without checking:
```c
struct event_base *base = e->event_base;  // Crashes if e is NULL
```

## Solution

Added a simple check before calling `set_ssl_ctx()`:

## Impact

-  Prevents crashes when `create_ioa_engine()` fails due to invalid
configuration
-  Minimal change with no functional impact on normal operation
-  All existing tests continue to pass
-  Follows defensive programming best practices

Fixes #1718.
2025-07-11 12:40:28 +02:00
Copilot
99984fbccd
Add configurable CPU count option for containerized environments (#1717)
This PR adds a new `--cpus` configuration option to address CPU
detection issues in virtualized and containerized environments where
`_SC_NPROCESSORS_CONF` and `_SC_NPROCESSORS_ONLN` return host CPU counts
instead of allocated container CPUs.

## Problem
In containerized deployments, coturn detects the host's CPU count (e.g.,
128 CPUs) instead of the container's allocated CPUs (e.g., 2 CPUs). This
causes the server to create excessive relay threads and database
connections, leading to resource exhaustion and performance issues.

## Solution
Added a new `cpus` configuration option that allows manual override of
CPU detection:

### Command Line Usage
```bash
turnserver --cpus 2
```

### Configuration File Usage
```ini
# Override system CPU count detection for containers
cpus=2
```

## Key Features
- **Backward Compatible**: No changes needed for existing deployments
- **Input Validation**: Values must be between 1 and 128 with proper
error handling
- **Comprehensive Documentation**: Updated man pages and example config
files
- **Both Interfaces**: Works via command line and configuration file

## Testing
The implementation has been thoroughly tested:

```bash
# Container with 2 allocated CPUs on 128-CPU host
$ turnserver --cpus 2
INFO: System cpu num is 128       # Host detection
INFO: System enable num is 128    # Host detection  
INFO: Configured cpu num is 2     # Override applied
INFO: Total General servers: 2    # Correct thread count
```

-  Command line option: `--cpus 8` creates 8 relay servers
-  Config file option: `cpus=6` creates 6 relay servers  
-  Error handling: Invalid values show appropriate errors
-  Default behavior: Without option, uses system detection
-  RFC5769 tests: All protocol tests still pass

## Files Modified
- `src/apps/relay/mainrelay.c` - Core implementation
- `src/apps/relay/mainrelay.h` - Added configuration flag
- `examples/etc/turnserver.conf` - Added documentation and example
- `man/man1/turnserver.1` - Updated man page

This change directly addresses the resource consumption issues in
containerized environments while maintaining full backward
compatibility.

Fixes #1628.
2025-07-10 15:37:02 +02:00
lhywk
5ab95e1a5a
Fix memory and resource leaks in udp_create_server_socket( ) (#1714)
### Describe

Hi,

Fixes resource and memory leaks in `udp_create_server_socket()` by
ensuring that the socket file descriptor (`udp_fd`) and dynamically
allocated memory (`server_addr`) are properly released on failure.

Specifically, if `addr_bind()`, `event_new()`, or `event_add()` fails,
the function now closes the socket and frees memory to prevent leaks.

### Expected Behavior

On any failure during socket binding or event registration, both
`udp_fd` and `server_addr` should be released to avoid leaking system
resources.

### Actual Behavior

Previously, if `addr_bind()`, `event_new()`, or `event_add()` failed,
the function would return early without closing the socket or freeing
memory, causing file descriptor and heap memory leaks.

This patch addresses overlooked memory and resource cleanup on failure
paths, improving server stability through targeted and essential
changes.

Thanks for reviewing.

Co-authored-by: Gustavo Garcia <gustavogb@gmail.com>
2025-07-03 10:23:59 +02:00
Shane
2944775261
Add define to disable OAuth support (#1713)
Redoing https://github.com/coturn/coturn/pull/1664 as requested. This
adds an optional OAUTH_DISABLED define to allow for disabling OAuth
support.
2025-07-02 11:36:50 +02:00
redraincatching
0f8cdde961
typo correction (#1715)
@ggarber i noticed too late that i used `0x03` instead of `0x02` by
mistake - this is an issue because it means that `add_requested_family`
will never be set when ipv6 is being used, so this should be fixed
2025-07-01 14:10:45 +02:00
tyranron
bc7cd74718
Update Debian "bookworm" to 20250630 snapshot in Docker image 2025-07-01 14:34:38 +03:00
redraincatching
a3a7450104
refactored tri-state to bools (#1709)
refactored random tri-state to use two random booleans for clarity
2025-07-01 12:41:22 +02:00
redraincatching
16f801f646
addressed null pointer deref warnings (#1712)
addressing issues raised by code scanning, specifically null pointer
dereferences in server

ns_turn_server.c
-
[33](https://github.com/redraincatching/coturn/security/code-scanning/33)
ignored, the `is_rfc5780()` function exits early if the server is null
- this also catches
[36](https://github.com/redraincatching/coturn/security/code-scanning/36)
-
[34](https://github.com/redraincatching/coturn/security/code-scanning/34)
addressed
-
[174](https://github.com/redraincatching/coturn/security/code-scanning/174)
addressed

ns_turn_maps.c
-
[27](https://github.com/redraincatching/coturn/security/code-scanning/27),
[160](https://github.com/redraincatching/coturn/security/code-scanning/160),
[161](https://github.com/redraincatching/coturn/security/code-scanning/161),
[162](https://github.com/redraincatching/coturn/security/code-scanning/162),
[163](https://github.com/redraincatching/coturn/security/code-scanning/163),
[164](https://github.com/redraincatching/coturn/security/code-scanning/164),
[165](https://github.com/redraincatching/coturn/security/code-scanning/165)
false positives, suppressed with assert()

ns_turn_allocations.c
-
[9](https://github.com/redraincatching/coturn/security/code-scanning/9)
addressed

---------

Co-authored-by: Gustavo Garcia <gustavogb@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-01 12:40:11 +02:00
redraincatching
cb74638149
removed unnecessary null check (#1706)
removing an unnecessary null check as raised in [this code
scan](https://github.com/redraincatching/coturn/security/code-scanning/179)

the variable is confirmed to not be null in an outer loop guard

also changed the name of the variable in `rtcp_map_put`'s function
declaration to match that used in its function definition
2025-06-20 09:51:52 -07:00
Gustavo Garcia
62d91b0bc5
Fix compiler warnings in source files (#1704)
Two compiler warnings were addressed:

* In `src/apps/relay/http_server.c`, line 77, a `-Wpointer-sign` warning
occurred when initializing a `char *` with the `uint8_t *` return type
of `ioa_network_buffer_data()`.
* An explicit cast `(char *)` was added to
`ioa_network_buffer_data(nbh_http)` to resolve the type mismatch.

* In `src/apps/relay/acme.c`, line 59, a `-Wchar-subscripts` warning was
present because a `char` variable `c` was used as an array index. `char`
can be signed, potentially leading to negative indices.
* Initially, `c` was cast to `(unsigned char)` at the point of use:
`A[(unsigned char)c]`.
* This was later improved by changing the declaration of `c` from `const
char` to `const unsigned char c = req[k]

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-06-17 15:25:26 +02:00
redraincatching
afec2e2add
guarantee no oob write in strncat (#1702)
based on [this codescanning
alert](https://github.com/redraincatching/coturn/security/code-scanning/166)

guarantees that the `turn_params.cipher_list` will be null-terminated,
and that the call to strncpy cannot attempt to access out-of-bounds
memory
2025-06-12 11:15:46 +02:00
Scott Godin
1368e65988
Fix issues with Global Allocation Count for drain mode (#1699)
Fix issues with Global Allocation Count for drain mode

- move increment/decrement logic out of userdb.c and tie to Prometheus
logic for allocation tracking instead
- log global allocation count decrements at INFO level, when drain mode
is on
2025-06-11 14:15:36 -07:00