[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [snowflake/master] Refactor subsetting of ice servers into main
commit 82031289a3362ff3fa199628276d76e840491431
Author: Cecylia Bocovich <cohosh@xxxxxxxxxxxxxx>
Date: Fri Jul 24 11:38:58 2020 -0400
Refactor subsetting of ice servers into main
This moves the subsetting of ice servers out of the parseIceServers
function and into main.
---
client/snowflake.go | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/client/snowflake.go b/client/snowflake.go
index c05431b..55bc48e 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -78,7 +78,6 @@ func socksAcceptLoop(ln *pt.SocksListener, snowflakes sf.SnowflakeCollector) {
}
// s is a comma-separated list of ICE server URLs.
-// chooses a random subset of servers from inputs
func parseIceServers(s string) []webrtc.ICEServer {
var servers []webrtc.ICEServer
s = strings.TrimSpace(s)
@@ -92,13 +91,6 @@ func parseIceServers(s string) []webrtc.ICEServer {
URLs: []string{url},
})
}
- rand.Seed(time.Now().Unix())
- rand.Shuffle(len(servers), func(i, j int) {
- servers[i], servers[j] = servers[j], servers[i]
- })
- if len(servers) > 2 {
- servers = servers[:len(servers)/2]
- }
return servers
}
@@ -153,6 +145,14 @@ func main() {
log.Println("\n\n\n --- Starting Snowflake Client ---")
iceServers := parseIceServers(*iceServersCommas)
+ // chooses a random subset of servers from inputs
+ rand.Seed(time.Now().UnixNano())
+ rand.Shuffle(len(iceServers), func(i, j int) {
+ iceServers[i], iceServers[j] = iceServers[j], iceServers[i]
+ })
+ if len(iceServers) > 2 {
+ iceServers = iceServers[:(len(iceServers)+1)/2]
+ }
log.Printf("Using ICE servers:")
for _, server := range iceServers {
log.Printf("url: %v", strings.Join(server.URLs, " "))
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits