Repository: pion/webrtc
Pull request #2471 (2023-05-13 20:53:51)

Update module github.com/pion/ice to v2.3.3
#### Description

This PR upgrades our pion/ice dependency to version 2.3.3.
https://github.com/pion/ice/releases/tag/v2.3.3



codecov[bot]: ## [Codecov](https://app.codecov.io/gh/pion/webrtc/pull/2471?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) Report
Patch coverage has no change and project coverage change: **`-7.58`** :warning:
> Comparison is base [(`683fc83`)](https://app.codecov.io/gh/pion/webrtc/commit/683fc837d0a7c9e66f672801adb0e5017c484c95?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) 77.73% compared to head [(`e6934ca`)](https://app.codecov.io/gh/pion/webrtc/pull/2471?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) 70.15%.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #2471      +/-   ##
==========================================
- Coverage   77.73%   70.15%   -7.58%     
==========================================
  Files          87       64      -23     
  Lines        9319     3354    -5965     
==========================================
- Hits         7244     2353    -4891     
+ Misses       1645      873     -772     
+ Partials      430      128     -302     
```

| Flag | Coverage Δ | |
|---|---|---|
| go | `?` | |
| wasm | `70.15% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#carryforward-flags-in-the-pull-request-comment) to find out more.

[see 47 files with indirect coverage changes](https://app.codecov.io/gh/pion/webrtc/pull/2471/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion)


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/pion/webrtc/pull/2471?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion).

Sean-Der: @stv0g i believe the API was broken? Would you mind reverting or aliasing. Not able to get on computer today sorry :/
Sean-Der: Amazing work @pougetat really excited to have you involved!
pougetat: > Amazing work @pougetat really excited to have you involved!
> 
> PR does change public API. Just want to make sure that is intentional re @stv0g
> 
> after that I think good to merge!

Yep sounds good, I'll wait for @stv0g to chime in. :)
stv0g: We have moved the ice.URL type to the stun package. So it was intentional.

However, I also kept backwards compatible aliases in the ice package, which should allow you to keep using ice.URL. However, these aliases are marked as deprecated.

See: https://github.com/pion/ice/blob/master/url.go#L12
Sean-Der: @stv0g great! So maybe we should just mark them `nolint` in WebRTC public API? 

Then no breakage for users? Or maybe it all works today I am not able to check 
pougetat: > @stv0g great! So maybe we should just mark them `nolint` in WebRTC public API?
> 
> Then no breakage for users? Or maybe it all works today I am not able to check

So just to be clear, the API breaking change is that we can no longer use ice package's `ConnectionState` type as a parameter to `pc.onIceConnectionStateChange` and instead we have to use webrtc's own `ICEConnectionState`.

I'm not sure that changing from `ice.URL` to `stun.URI` breaks webrtc's public API (unless I'm missing something?)
Sean-Der: Thanks for the research @pougetat that helps a lot :) I am going to merge this now. 


The `pion/ice` API breakage is unfortunate, but I think it would be worse to flip it back now? We can address the churn with `pion/ice` users as they file issues. 

This has been discussed before https://github.com/pion/webrtc/issues/1293 unfortunately it breaks the public API/causes problems. 

Patch:
diff --git a/AUTHORS.txt b/AUTHORS.txt
index 24ef9894..1892431f 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -146,6 +146,7 @@ Patrice Ferlet <patrice.ferlet@smile.fr>
 Patrick Lange <mail@langep.com>
 Patryk Rogalski <digitalix4@gmail.com>
 Pieere Pi <pihuibin@hotmail.com>
+Pouget-Abadie <thomas.pougetabadie@gmail.com>
 q191201771 <191201771@qq.com>
 Quentin Renard <contact@asticode.com>
 Rafael Viscarra <rafael@viscarra.dev>
diff --git a/go.mod b/go.mod
index 7c935176..7f7f96aa 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@ require (
 	github.com/onsi/gomega v1.17.0 // indirect
 	github.com/pion/datachannel v1.5.5
 	github.com/pion/dtls/v2 v2.2.6
-	github.com/pion/ice/v2 v2.3.2
+	github.com/pion/ice/v2 v2.3.3
 	github.com/pion/interceptor v0.1.16
 	github.com/pion/logging v0.2.2
 	github.com/pion/randutil v0.1.0
@@ -16,9 +16,9 @@ require (
 	github.com/pion/sctp v1.8.7
 	github.com/pion/sdp/v3 v3.0.6
 	github.com/pion/srtp/v2 v2.0.13
+	github.com/pion/stun v0.5.2
 	github.com/pion/transport/v2 v2.2.0
 	github.com/sclevine/agouti v3.0.0+incompatible
 	github.com/stretchr/testify v1.8.2
-	golang.org/x/crypto v0.6.0 // indirect
-	golang.org/x/net v0.9.0
+	golang.org/x/net v0.10.0
 )
diff --git a/go.sum b/go.sum
index 34b2a18b..4371f84e 100644
--- a/go.sum
+++ b/go.sum
@@ -44,8 +44,8 @@ github.com/pion/datachannel v1.5.5 h1:10ef4kwdjije+M9d7Xm9im2Y3O6A6ccQb0zcqZcJew
 github.com/pion/datachannel v1.5.5/go.mod h1:iMz+lECmfdCMqFRhXhcA/219B0SQlbpoR2V118yimL0=
 github.com/pion/dtls/v2 v2.2.6 h1:yXMxKr0Skd+Ub6A8UqXTRLSywskx93ooMRHsQUtd+Z4=
 github.com/pion/dtls/v2 v2.2.6/go.mod h1:t8fWJCIquY5rlQZwA2yWxUS1+OCrAdXrhVKXB5oD/wY=
-github.com/pion/ice/v2 v2.3.2 h1:vh+fi4RkZ8H5fB4brZ/jm3j4BqFgMmNs+aB3X52Hu7M=
-github.com/pion/ice/v2 v2.3.2/go.mod h1:AMIpuJqcpe+UwloocNebmTSWhCZM1TUCo9v7nW50jX0=
+github.com/pion/ice/v2 v2.3.3 h1:uGrUwn0DanTmXgFiKDTot7iQzo0J9NjTjHPG+Kt+kNE=
+github.com/pion/ice/v2 v2.3.3/go.mod h1:jVbxqPWQDK5+/V/YqpinUcP0YtDGYqd24n2lusVdX80=
 github.com/pion/interceptor v0.1.16 h1:0GDZrfNO+BmVNWymS31fMlVtPO2IJVBzy2Qq5XCYMIg=
 github.com/pion/interceptor v0.1.16/go.mod h1:SY8kpmfVBvrbUzvj2bsXz7OJt5JvmVNZ+4Kjq7FcwrI=
 github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
@@ -65,8 +65,9 @@ github.com/pion/sdp/v3 v3.0.6 h1:WuDLhtuFUUVpTfus9ILC4HRyHsW6TdugjEX/QY9OiUw=
 github.com/pion/sdp/v3 v3.0.6/go.mod h1:iiFWFpQO8Fy3S5ldclBkpXqmWy02ns78NOKoLLL0YQw=
 github.com/pion/srtp/v2 v2.0.13 h1:GJQNMCqbYrNIBt1f3maX+E+woREVh2ilhAafBh0vqmk=
 github.com/pion/srtp/v2 v2.0.13/go.mod h1:FA7u5fWpVITMYNL70TA3csQuMQJA5/+6ZMajGxveHgM=
-github.com/pion/stun v0.4.0 h1:vgRrbBE2htWHy7l3Zsxckk7rkjnjOsSM7PHZnBwo8rk=
 github.com/pion/stun v0.4.0/go.mod h1:QPsh1/SbXASntw3zkkrIk3ZJVKz4saBY2G7S10P3wCw=
+github.com/pion/stun v0.5.2 h1:J/8glQnDV91dfk2+ZnGN0o9bUJgABhTNljwfQWByoXE=
+github.com/pion/stun v0.5.2/go.mod h1:TNo1HjyjaFVpMZsvowqPeV8TfwRytympQC0//neaksA=
 github.com/pion/transport v0.14.1 h1:XSM6olwW+o8J4SCmOBb/BpwZypkHeyM0PGFCxNQBr40=
 github.com/pion/transport v0.14.1/go.mod h1:4tGmbk00NeYA3rUa9+n+dzCCoKkcy3YlYb99Jn2fNnI=
 github.com/pion/transport/v2 v2.0.0/go.mod h1:HS2MEBJTwD+1ZI2eSXSvHJx/HnzQqRy2/LXxt6eVMHc=
@@ -98,8 +99,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
-golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
-golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
+golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
+golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
 golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
@@ -116,8 +117,8 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
 golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
 golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
 golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
-golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
-golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
+golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
+golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -142,15 +143,16 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
 golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
+golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
 golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
 golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
-golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
+golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
diff --git a/icegatherer.go b/icegatherer.go
index 17aa0172..cf12b420 100644
--- a/icegatherer.go
+++ b/icegatherer.go
@@ -13,6 +13,7 @@ import (
 
 	"github.com/pion/ice/v2"
 	"github.com/pion/logging"
+	"github.com/pion/stun"
 )
 
 // ICEGatherer gathers local host, server reflexive and relay
@@ -24,7 +25,7 @@ type ICEGatherer struct {
 	log   logging.LeveledLogger
 	state ICEGathererState
 
-	validatedServers []*ice.URL
+	validatedServers []*stun.URI
 	gatherPolicy     ICETransportPolicy
 
 	agent *ice.Agent
@@ -42,7 +43,7 @@ type ICEGatherer struct {
 // This constructor is part of the ORTC API. It is not
 // meant to be used together with the basic WebRTC API.
 func (api *API) NewICEGatherer(opts ICEGatherOptions) (*ICEGatherer, error) {
-	var validatedServers []*ice.URL
+	var validatedServers []*stun.URI
 	if len(opts.ICEServers) > 0 {
 		for _, server := range opts.ICEServers {
 			url, err := server.urls()
diff --git a/iceserver.go b/iceserver.go
index 49e838f5..35d231fd 100644
--- a/iceserver.go
+++ b/iceserver.go
@@ -9,7 +9,7 @@ package webrtc
 import (
 	"encoding/json"
 
-	"github.com/pion/ice/v2"
+	"github.com/pion/stun"
 	"github.com/pion/webrtc/v3/pkg/rtcerr"
 )
 
@@ -22,8 +22,8 @@ type ICEServer struct {
 	CredentialType ICECredentialType `json:"credentialType,omitempty"`
 }
 
-func (s ICEServer) parseURL(i int) (*ice.URL, error) {
-	return ice.ParseURL(s.URLs[i])
+func (s ICEServer) parseURL(i int) (*stun.URI, error) {
+	return stun.ParseURI(s.URLs[i])
 }
 
 func (s ICEServer) validate() error {
@@ -31,8 +31,8 @@ func (s ICEServer) validate() error {
 	return err
 }
 
-func (s ICEServer) urls() ([]*ice.URL, error) {
-	urls := []*ice.URL{}
+func (s ICEServer) urls() ([]*stun.URI, error) {
+	urls := []*stun.URI{}
 
 	for i := range s.URLs {
 		url, err := s.parseURL(i)
@@ -40,7 +40,7 @@ func (s ICEServer) urls() ([]*ice.URL, error) {
 			return nil, &rtcerr.InvalidAccessError{Err: err}
 		}
 
-		if url.Scheme == ice.SchemeTypeTURN || url.Scheme == ice.SchemeTypeTURNS {
+		if url.Scheme == stun.SchemeTypeTURN || url.Scheme == stun.SchemeTypeTURNS {
 			// https://www.w3.org/TR/webrtc/#set-the-configuration (step #11.3.2)
 			if s.Username == "" || s.Credential == nil {
 				return nil, &rtcerr.InvalidAccessError{Err: ErrNoTurnCredentials}


Test patch:
diff --git a/iceserver_test.go b/iceserver_test.go
index e9363193..955c0208 100644
--- a/iceserver_test.go
+++ b/iceserver_test.go
@@ -10,7 +10,7 @@ import (
 	"encoding/json"
 	"testing"
 
-	"github.com/pion/ice/v2"
+	"github.com/pion/stun"
 	"github.com/pion/webrtc/v3/pkg/rtcerr"
 	"github.com/stretchr/testify/assert"
 )
@@ -86,7 +86,7 @@ func TestICEServer_validate(t *testing.T) {
 				Username:       "unittest",
 				Credential:     false,
 				CredentialType: ICECredentialTypeOauth,
-			}, &rtcerr.InvalidAccessError{Err: ice.ErrSTUNQuery}},
+			}, &rtcerr.InvalidAccessError{Err: stun.ErrSTUNQuery}},
 		}
 
 		for i, testCase := range testCases {
diff --git a/peerconnection_go_test.go b/peerconnection_go_test.go
index a39bc7e9..b51a0c65 100644
--- a/peerconnection_go_test.go
+++ b/peerconnection_go_test.go
@@ -304,7 +304,7 @@ func TestPeerConnection_EventHandlers_Go(t *testing.T) {
 
 	// Verify that the noop case works
 	assert.NotPanics(t, func() { pc.onTrack(nil, nil) })
-	assert.NotPanics(t, func() { pc.onICEConnectionStateChange(ice.ConnectionStateNew) })
+	assert.NotPanics(t, func() { pc.onICEConnectionStateChange(ICEConnectionStateNew) })
 
 	pc.OnTrack(func(t *TrackRemote, r *RTPReceiver) {
 		close(onTrackCalled)
@@ -329,7 +329,7 @@ func TestPeerConnection_EventHandlers_Go(t *testing.T) {
 
 	// Verify that the set handlers are called
 	assert.NotPanics(t, func() { pc.onTrack(&TrackRemote{}, &RTPReceiver{}) })
-	assert.NotPanics(t, func() { pc.onICEConnectionStateChange(ice.ConnectionStateNew) })
+	assert.NotPanics(t, func() { pc.onICEConnectionStateChange(ICEConnectionStateNew) })
 	assert.NotPanics(t, func() { go pc.onDataChannelHandler(&DataChannel{api: api}) })
 
 	<-onTrackCalled