config)); $cacheTtl = (int) ($this->config['cache_ttl'] ?? 600); $servers = Cache::remember($cacheKey, now()->addSeconds($cacheTtl), function () { $list = []; // 1. STUN servers $stunUrls = $this->config['stun_urls'] ?? ['stun:stun.convexsol.com:3478', 'stun:stun.l.google.com:19302']; if (is_string($stunUrls)) { $stunUrls = array_filter(array_map('trim', explode(',', $stunUrls))); } if (! empty($stunUrls)) { $list[] = [ 'urls' => array_values($stunUrls), ]; } // 2. TURN servers with username and password $turnUrls = $this->config['turn_urls'] ?? ['turn:turn.convexsol.com:3478', 'turns:turn.convexsol.com:5349']; if (is_string($turnUrls)) { $turnUrls = array_filter(array_map('trim', explode(',', $turnUrls))); } $username = $this->config['username'] ?? null; $password = $this->config['password'] ?? null; if (! empty($turnUrls)) { $turnEntry = [ 'urls' => array_values($turnUrls), ]; if ($username !== null) { $turnEntry['username'] = $username; } if ($password !== null) { $turnEntry['credential'] = $password; } $list[] = $turnEntry; } return $list; }); return IceCandidatesDto::fromArray($servers); } }