[tor-commits] [snowflake/master] Bump version of pion/sdp

cohosh at torproject.org cohosh at torproject.org
Mon Jan 25 15:43:08 UTC 2021


commit 1b29ad7de14fb0a6d2bf88aea38353733682cd26
Author: Cecylia Bocovich <cohosh at torproject.org>
Date:   Mon Jan 25 10:28:17 2021 -0500

    Bump version of pion/sdp
    
    Update our dependency on pion/sdp from v2 to v3, to match pion/webrtc
    v3. This requires some changes in how we parse out addresses from ice
    candidates. This will ease tor browser builds of snowflake since we are
    now only relying on one version of pion/sdp instead of two different
    ones.
---
 common/util/util.go | 9 +++++----
 go.mod              | 3 ++-
 go.sum              | 2 --
 proxy/snowflake.go  | 7 ++++---
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/common/util/util.go b/common/util/util.go
index 3d2acc3..00f7302 100644
--- a/common/util/util.go
+++ b/common/util/util.go
@@ -5,7 +5,8 @@ import (
 	"errors"
 	"net"
 
-	"github.com/pion/sdp/v2"
+	"github.com/pion/ice/v2"
+	"github.com/pion/sdp/v3"
 	"github.com/pion/webrtc/v3"
 )
 
@@ -77,9 +78,9 @@ func StripLocalAddresses(str string) string {
 		attrs := make([]sdp.Attribute, 0)
 		for _, a := range m.Attributes {
 			if a.IsICECandidate() {
-				ice, err := a.ToICECandidate()
-				if err == nil && ice.Typ == "host" {
-					ip := net.ParseIP(ice.Address)
+				c, err := ice.UnmarshalCandidate(a.Value)
+				if err == nil && c.Type() == ice.CandidateTypeHost {
+					ip := net.ParseIP(c.Address())
 					if ip != nil && (IsLocal(ip) || ip.IsUnspecified() || ip.IsLoopback()) {
 						/* no append in this case */
 						continue
diff --git a/go.mod b/go.mod
index 2931be7..a7f9ad2 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,8 @@ go 1.13
 require (
 	git.torproject.org/pluggable-transports/goptlib.git v1.1.0
 	github.com/gorilla/websocket v1.4.1
-	github.com/pion/sdp/v2 v2.3.4
+	github.com/pion/ice/v2 v2.0.14
+	github.com/pion/sdp/v3 v3.0.3
 	github.com/pion/stun v0.3.5
 	github.com/pion/webrtc/v3 v3.0.0
 	github.com/smartystreets/goconvey v1.6.4
diff --git a/go.sum b/go.sum
index 6214f5c..eac95e1 100644
--- a/go.sum
+++ b/go.sum
@@ -66,8 +66,6 @@ github.com/pion/rtp v1.6.2/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko
 github.com/pion/sctp v1.7.10/go.mod h1:EhpTUQu1/lcK3xI+eriS6/96fWetHGCvBi9MSsnaBN0=
 github.com/pion/sctp v1.7.11 h1:UCnj7MsobLKLuP/Hh+JMiI/6W5Bs/VF45lWKgHFjSIE=
 github.com/pion/sctp v1.7.11/go.mod h1:EhpTUQu1/lcK3xI+eriS6/96fWetHGCvBi9MSsnaBN0=
-github.com/pion/sdp/v2 v2.3.4 h1:+f3F5Xl7ynVhc9Il8Dc7BFroYJWG3PMbfWtwFlVI+kg=
-github.com/pion/sdp/v2 v2.3.4/go.mod h1:jccXVYW0fuK6ds2pwKr89SVBDYlCjhgMI6nucl5R5rA=
 github.com/pion/sdp/v3 v3.0.3 h1:gJK9hk+JFD2NGIM1nXmqNCq1DkVaIZ9dlA3u3otnkaw=
 github.com/pion/sdp/v3 v3.0.3/go.mod h1:bNiSknmJE0HYBprTHXKPQ3+JjacTv5uap92ueJZKsRk=
 github.com/pion/srtp/v2 v2.0.0-rc.3 h1:1fPiK1nJlNyh235tSGgBnXrPc99wK1/D707f6ntb3qY=
diff --git a/proxy/snowflake.go b/proxy/snowflake.go
index 78a053d..1bc21ab 100644
--- a/proxy/snowflake.go
+++ b/proxy/snowflake.go
@@ -23,7 +23,8 @@ import (
 	"git.torproject.org/pluggable-transports/snowflake.git/common/util"
 	"git.torproject.org/pluggable-transports/snowflake.git/common/websocketconn"
 	"github.com/gorilla/websocket"
-	"github.com/pion/sdp/v2"
+	"github.com/pion/ice/v2"
+	"github.com/pion/sdp/v3"
 	"github.com/pion/webrtc/v3"
 )
 
@@ -83,9 +84,9 @@ func remoteIPFromSDP(str string) net.IP {
 	for _, m := range desc.MediaDescriptions {
 		for _, a := range m.Attributes {
 			if a.IsICECandidate() {
-				ice, err := a.ToICECandidate()
+				c, err := ice.UnmarshalCandidate(a.Value)
 				if err == nil {
-					ip := net.ParseIP(ice.Address)
+					ip := net.ParseIP(c.Address())
 					if ip != nil && isRemoteAddress(ip) {
 						return ip
 					}



More information about the tor-commits mailing list