[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [pluggable-transports/snowflake] 01/03: Parse ICE servers with pion/ice library function



This is an automated email from the git hooks/post-receive script.

itchyonion pushed a commit to branch main
in repository pluggable-transports/snowflake.

commit a6a18c1a9b004bda644b0b790ca756af0c6b1e51
Author: itchyonion <itchyonion@xxxxxxxxxxxxxx>
AuthorDate: Tue Dec 6 15:52:59 2022 -0800

    Parse ICE servers with pion/ice library function
---
 client/lib/lib_test.go  | 13 +++++++++----
 client/lib/snowflake.go | 11 ++++++++++-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/client/lib/lib_test.go b/client/lib/lib_test.go
index e1b6427..93fe0ad 100644
--- a/client/lib/lib_test.go
+++ b/client/lib/lib_test.go
@@ -195,15 +195,20 @@ func TestICEServerParser(t *testing.T) {
 				1,
 			},
 			{
-				[]string{"stun:stun.l.google.com:19302", "stun.ekiga.net"},
-				[][]string{[]string{"stun:stun.l.google.com:19302"}, []string{"stun.ekiga.net"}},
+				[]string{"stun:stun.l.google.com", "stuns:stun.ekiga.net"},
+				[][]string{[]string{"stun:stun.l.google.com:3478"}, []string{"stuns:stun.ekiga.net:5349"}},
 				2,
 			},
 			{
-				[]string{"stun:stun.l.google.com:19302", "stun.ekiga.net"},
-				[][]string{[]string{"stun:stun.l.google.com:19302"}, []string{"stun.ekiga.net"}},
+				[]string{"stuns:stun.l.google.com:19302", "turn:relay.metered.ca:80"},
+				[][]string{[]string{"stuns:stun.l.google.com:19302"}, []string{"turn:relay.metered.ca:80?transport=udp"}},
 				2,
 			},
+			{
+				[]string{"stun:stun1.l.google.com:19302", "stun.ekiga.net", "stun:stun.example.com:1234/path?query", "https://example.com"},
+				[][]string{[]string{"stun:stun1.l.google.com:19302"}},
+				1,
+			},
 		} {
 			servers := parseIceServers(test.input)
 
diff --git a/client/lib/snowflake.go b/client/lib/snowflake.go
index c587e6d..5d19c55 100644
--- a/client/lib/snowflake.go
+++ b/client/lib/snowflake.go
@@ -37,6 +37,7 @@ import (
 	"git.torproject.org/pluggable-transports/snowflake.git/v2/common/event"
 	"git.torproject.org/pluggable-transports/snowflake.git/v2/common/nat"
 	"git.torproject.org/pluggable-transports/snowflake.git/v2/common/turbotunnel"
+	"github.com/pion/ice/v2"
 	"github.com/pion/webrtc/v3"
 	"github.com/xtaci/kcp-go/v5"
 	"github.com/xtaci/smux"
@@ -269,8 +270,16 @@ func parseIceServers(addresses []string) []webrtc.ICEServer {
 	}
 	for _, url := range addresses {
 		url = strings.TrimSpace(url)
+
+		// add default port, other sanity checks
+		parsedURL, err := ice.ParseURL(url)
+		if err != nil {
+			log.Printf("Warning: Parsing ICE server %v resulted in error: %v, skipping", url, err)
+			continue
+		}
+
 		servers = append(servers, webrtc.ICEServer{
-			URLs: []string{url},
+			URLs: []string{parsedURL.String()},
 		})
 	}
 	return servers

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits