webrtc: apply operator ICEServers override in subsystem.New for issue #23
Some checks failed
ci / race tests (push) Blocked by required conditions
ci / WebRTC smoke (5-viewer fanout) (push) Blocked by required conditions
ci / WebRTC latency p95 gate (push) Blocked by required conditions
ci / vet + build (push) Has been cancelled

This commit is contained in:
Zac Gaetano 2026-05-10 21:15:42 -04:00
parent b6d2a77f8b
commit 4364d9176f

View file

@ -85,6 +85,14 @@ func New(dataCfg config.DataWebRTC, logger log.Logger) (*Subsystem, error) {
}
coreCfg.NAT1To1IPs = nat1to1IPs
// If the operator supplied explicit ICE server URIs via config/env,
// override the built-in defaults (typically Google's public STUN servers).
// An empty list means "keep the built-in defaults".
if len(dataCfg.ICEServers) > 0 {
coreCfg.ICEServers = make([]string, len(dataCfg.ICEServers))
copy(coreCfg.ICEServers, dataCfg.ICEServers)
}
factory, err := corewebrtc.NewPeerFactory(coreCfg)
if err != nil {
return nil, fmt.Errorf("webrtc subsystem: build peer factory: %w", err)
@ -190,9 +198,11 @@ func (s *Subsystem) StreamCount() int {
}
// ICEServerURIs returns the ICE server URI list from the core config.
// Used by the WHEP handler to emit RFC 9429 §4.3 Link headers so that
// browsers can discover STUN/TURN servers without a separate signalling
// round-trip.
// Used by the WHEP and WHIP handlers to emit RFC 9429 / RFC 9261 Link
// headers so that browsers can discover STUN/TURN servers without a
// separate signalling round-trip. If the operator configured explicit
// servers via CORE_WEBRTC_ICE_SERVERS those are returned; otherwise
// the built-in Pion defaults are returned.
func (s *Subsystem) ICEServerURIs() []string {
return s.coreCfg.ICEServers
}