1
0
mirror of https://github.com/coturn/coturn.git synced 2026-10-24 00:08:57 +03:00

6 Commits

Author SHA1 Message Date
Pavel Punsky
d8107aff80 build: pin openssl@3 on macOS CI and reject mixed OpenSSL majors (#2095)
## Problem

Every macOS job in CI currently fails: `turnserver` segfaults on the
first TLS client in `examples/run_tests.sh` (e.g. run 37231739523 on
#2093, which only touches `dbd_sqlite.c`).

Cause: Homebrew's `openssl` formula now resolves to `openssl@4` (4.0.3),
but the libevent bottle's `libevent_openssl` still links `openssl@3`.
coturn builds against OpenSSL 4 and passes its `SSL*` to libevent
running on OpenSSL 3 via `bufferevent_openssl_socket_new`, which crashes
in `SSL_set_bio`. macOS two-level namespaces keep both copies loaded.

## Changes

- `.github/workflows/macos.yml`: install `openssl@3` and export
`OPENSSL_ROOT_DIR` / `PKG_CONFIG_PATH` for both the autotools and CMake
jobs.
- `cmake/CheckLibeventOpenSSL.cmake` (new), used from
`src/apps/common/CMakeLists.txt`: on macOS, fail configure when
`libevent_openssl` links a different OpenSSL major than the one found.
- `configure`: same check for the autotools build (Darwin only).
- `TURN_ALLOW_OPENSSL_MISMATCH` (CMake option / env var) overrides the
check.

## Testing

On macOS (both `openssl@3` 3.6.5 and `openssl@4` 4.0.3 installed):
- CMake configure with the default OpenSSL (`openssl@4`) fails with the
new error. With `-DOPENSSL_ROOT_DIR=$(brew --prefix openssl@3)` it
passes, and `-DTURN_ALLOW_OPENSSL_MISMATCH=ON` also passes.
- `./configure` with `openssl@4` first on `PKG_CONFIG_PATH` aborts; with
`openssl@3` first it passes, and the override also passes.
- With the `openssl@3` build: `ctest` 21/21, and `run_tests.sh`
(TCP/TLS/UDP/DTLS), `run_tests_conf`, `dtls_default`, `ipv6_relay`,
`mobility_quota`, `mobility_resume_flood`, `stateless_binding`,
`stateless_nonce` all pass with no FAIL or segfault.

On Linux (Docker): CMake configure, build and `ctest` (20/20) pass; the
check is a no-op there. I did not complete the Linux `run_tests*.sh`
pass.

The PR's own macOS CI jobs are the real end-to-end check.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 13:59:16 -07:00
Pavel Punsky
1ec81eff10 Build Prometheus exporter from vendored local sources (#1955)
## Summary

The Prometheus exporter previously linked the
[digitalocean/prometheus-client-c](https://github.com/digitalocean/prometheus-client-c)
(`prom`) library, which is **no longer maintained**. This replaces it
with a minimal, self-contained Prometheus client under `src/prometheus/`
that is built straight from coturn's own sources and implements exactly
the slice of the API coturn uses: counters, gauges, a single default
registry, and the text-exposition serializer.

The vendored client is **drop-in API-compatible**, so `prom_server.c` is
unchanged. Histograms, summaries, custom registries and the upstream
`promhttp` handler are intentionally omitted (coturn serves `/metrics`
with its own libmicrohttpd handler).

The exporter is now **always compiled in**; the runtime `--prometheus`
flag still controls whether it starts. **libmicrohttpd** — actively
maintained — is the only remaining external dependency and is now
required by the build.

## Changes

- **`src/prometheus/{prom.h,prom.c}`** — vendored client. Thread-safe
(per-metric mutex on the increment path, read under lock in the bridge),
label-aware, with proper Prometheus value/label escaping and clean
integer formatting for counters. No deps beyond pthread/libc.
- **CMake** — replace `find_package(Prometheus)` with required
`find_package(MicroHTTPD)`; add `cmake/FindMicroHTTPD.cmake`; remove
dead `cmake/FindPrometheus.cmake` and the `WITH_PROMETHEUS` option.
- **`configure` / `Makefile.in`** — drop `-lprom`, compile the vendored
source.
- **Docker** (`debian`, `alpine`) and **CI** (`ubuntu-build-deps`,
`mingw`) — remove the `prometheus-client-c` build/install steps; keep
libmicrohttpd.
- **`docs/Prometheus.md`** rewritten.
- **`tests/test_prometheus.c`** — Unity tests for counter
accumulation/monotonicity, gauge inc/dec, and label-value escaping.

## Validation

- Full build green; all unit tests pass (incl. new `test_prometheus`);
`clang-format-15` clean.
- Live exporter scraped over HTTP — all `run_tests_prom.sh` scenarios
(default / custom address / port / path, plus the negative case) pass.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 18:58:30 -07:00
Alex Gustafsson
d63704c72d Implement custom prometheus http handler (#1591)
Implement a custom prometheus http handler in order to:

1. Support listening on a specified address as opposed to any
2. Remove the requirement on the unmaintained promhttp library

This feature comes with one limitation: if an IPv4 address is used, the
server will not listen on the IPv6-mapped address, even if IPv6 is
available. That is, dual-stacking does not work.

Solves: #1475

---------

Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2024-12-10 10:28:43 -08:00
Kang Lin
294f897ccd CMake: find prometheus(fix #1304) (#1315)
fix #1304
2023-11-22 20:34:53 -08: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
KangLin
677e5dc5d3 Add cmake 2021-02-26 09:02:50 +08:00