Files
ac-ms-sfu-signaling/public/health.php
Anton Afanasyeu aa98516d3e SFU health: expose ice_servers for WebRTC clients (M2).
Include coturn turn_host credentials from lab config alongside public STUN.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-07 22:45:52 +02:00

41 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
require_once dirname(__DIR__) . '/src/bootstrap.php';
header('Content-Type: application/json; charset=utf-8');
$janus = janusClient();
$info = $janus->info();
$online = isset($info['janus']) && $info['janus'] === 'server_info';
$turnHost = trim((string) sfuConfig('turn_host', ''));
$turnPort = (int) sfuConfig('turn_port', 3478);
$turnUser = trim((string) sfuConfig('turn_user', ''));
$turnPass = trim((string) sfuConfig('turn_pass', ''));
$iceServers = [
['urls' => 'stun:stun.l.google.com:19302'],
['urls' => 'stun:stun1.l.google.com:19302'],
];
if ($turnHost !== '') {
$iceServers[] = [
'urls' => 'turn:' . $turnHost . ':' . $turnPort . '?transport=udp',
'username' => $turnUser,
'credential' => $turnPass,
];
}
echo json_encode([
'ok' => true,
'sfu' => [
'enabled' => true,
'status' => $online ? 'online' : 'unreachable',
'janus_version' => $info['version_string'] ?? null,
'janus_url' => sfuConfig('janus_url', 'http://10.7.16.237:8088/janus'),
'signaling_url' => sfuConfig('signaling_url', 'wss://apps.f0xx.org/app/androidcast_project/sfu/ws'),
'ws_url' => '/app/androidcast_project/sfu/ws',
'api_base' => '/app/androidcast_project/sfu/api',
'ice_servers' => $iceServers,
'turn_host' => $turnHost !== '' ? $turnHost : null,
],
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);