File: configuration_common.go

package info (click to toggle)
golang-github-pion-webrtc.v3 3.1.56-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,392 kB
  • sloc: javascript: 595; sh: 28; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package webrtc

import "strings"

// getICEServers side-steps the strict parsing mode of the ice package
// (as defined in https://tools.ietf.org/html/rfc7064) by copying and then
// stripping any erroneous queries from "stun(s):" URLs before parsing.
func (c Configuration) getICEServers() []ICEServer {
	iceServers := append([]ICEServer{}, c.ICEServers...)

	for iceServersIndex := range iceServers {
		iceServers[iceServersIndex].URLs = append([]string{}, iceServers[iceServersIndex].URLs...)

		for urlsIndex, rawURL := range iceServers[iceServersIndex].URLs {
			if strings.HasPrefix(rawURL, "stun") {
				// strip the query from "stun(s):" if present
				parts := strings.Split(rawURL, "?")
				rawURL = parts[0]
			}
			iceServers[iceServersIndex].URLs[urlsIndex] = rawURL
		}
	}
	return iceServers
}