github.com/pion/webrtc/v3@v3.2.24/configuration_common.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 package webrtc 5 6 import "strings" 7 8 // getICEServers side-steps the strict parsing mode of the ice package 9 // (as defined in https://tools.ietf.org/html/rfc7064) by copying and then 10 // stripping any erroneous queries from "stun(s):" URLs before parsing. 11 func (c Configuration) getICEServers() []ICEServer { 12 iceServers := append([]ICEServer{}, c.ICEServers...) 13 14 for iceServersIndex := range iceServers { 15 iceServers[iceServersIndex].URLs = append([]string{}, iceServers[iceServersIndex].URLs...) 16 17 for urlsIndex, rawURL := range iceServers[iceServersIndex].URLs { 18 if strings.HasPrefix(rawURL, "stun") { 19 // strip the query from "stun(s):" if present 20 parts := strings.Split(rawURL, "?") 21 rawURL = parts[0] 22 } 23 iceServers[iceServersIndex].URLs[urlsIndex] = rawURL 24 } 25 } 26 return iceServers 27 }