Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
47 lines
996 B
Go
47 lines
996 B
Go
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build js && wasm
|
|
// +build js,wasm
|
|
|
|
package webrtc
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/pion/ice/v4"
|
|
)
|
|
|
|
// ICEServer describes a single STUN and TURN server that can be used by
|
|
// the ICEAgent to establish a connection with a peer.
|
|
type ICEServer struct {
|
|
URLs []string
|
|
Username string
|
|
// Note: TURN is not supported in the WASM bindings yet
|
|
Credential any
|
|
CredentialType ICECredentialType
|
|
}
|
|
|
|
func (s ICEServer) parseURL(i int) (*ice.URL, error) {
|
|
return ice.ParseURL(s.URLs[i])
|
|
}
|
|
|
|
func (s ICEServer) validate() ([]*ice.URL, error) {
|
|
urls := []*ice.URL{}
|
|
|
|
for i := range s.URLs {
|
|
url, err := s.parseURL(i)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if url.Scheme == ice.SchemeTypeTURN || url.Scheme == ice.SchemeTypeTURNS {
|
|
return nil, errors.New("TURN is not currently supported in the JavaScript/Wasm bindings")
|
|
}
|
|
|
|
urls = append(urls, url)
|
|
}
|
|
|
|
return urls, nil
|
|
}
|