github.com/pion/webrtc/v3@v3.2.24/iceserver_js.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 //go:build js && wasm 5 // +build js,wasm 6 7 package webrtc 8 9 import ( 10 "errors" 11 12 "github.com/pion/ice/v2" 13 ) 14 15 // ICEServer describes a single STUN and TURN server that can be used by 16 // the ICEAgent to establish a connection with a peer. 17 type ICEServer struct { 18 URLs []string 19 Username string 20 // Note: TURN is not supported in the WASM bindings yet 21 Credential interface{} 22 CredentialType ICECredentialType 23 } 24 25 func (s ICEServer) parseURL(i int) (*ice.URL, error) { 26 return ice.ParseURL(s.URLs[i]) 27 } 28 29 func (s ICEServer) validate() ([]*ice.URL, error) { 30 urls := []*ice.URL{} 31 32 for i := range s.URLs { 33 url, err := s.parseURL(i) 34 if err != nil { 35 return nil, err 36 } 37 38 if url.Scheme == ice.SchemeTypeTURN || url.Scheme == ice.SchemeTypeTURNS { 39 return nil, errors.New("TURN is not currently supported in the JavaScript/Wasm bindings") 40 } 41 42 urls = append(urls, url) 43 } 44 45 return urls, nil 46 }