GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 92520f68 authored by Cecylia Bocovich's avatar Cecylia Bocovich

Choose a random subset from given STUN servers

Only chooses a subset as long as we have over 2 STUN servers to choose
from.
parent eaac9f5b
......@@ -49,8 +49,8 @@ func TestICEServerParser(t *testing.T) {
So(len(servers), ShouldEqual, test.length)
for i, server := range servers {
So(server.URLs, ShouldResemble, test.urls[i])
for _, server := range servers {
So(test.urls, ShouldContain, server.URLs)
}
}
......
......@@ -6,6 +6,7 @@ import (
"io"
"io/ioutil"
"log"
"math/rand"
"net"
"os"
"os/signal"
......@@ -77,6 +78,7 @@ 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)
......@@ -90,6 +92,13 @@ 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
}
......
......@@ -4,7 +4,7 @@ DataDirectory datadir
ClientTransportPlugin snowflake exec ./client \
-url https://snowflake-broker.azureedge.net/ \
-front ajax.aspnetcdn.com \
-ice stun:stun.l.google.com:19302 \
-ice stun:stun.voip.blackberry.com:3478,stun:stun.altar.com.pl:3478,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.com:3478,stun:stun.sonetel.net:3478,stun:stun.stunprotocol.org:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 \
-max 3
Bridge snowflake 192.0.2.3:1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment