Probetest/proxy: Set multiple comma-separated default STUN URLs

This adds the BlackBerry STUN server alongside Google's. Closes #40392.
This commit is contained in:
Neel Chauhan 2024-10-14 15:50:00 -04:00 committed by Cecylia Bocovich
parent 1085d048b9
commit 9ff205dd7f
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90
3 changed files with 14 additions and 10 deletions

View file

@ -29,10 +29,14 @@ import (
) )
const ( const (
readLimit = 100000 //Maximum number of bytes to be read from an HTTP request // Maximum number of bytes to be read from an HTTP request
dataChannelOpenTimeout = 20 * time.Second //time after which we assume proxy data channel will not open readLimit = 100000
dataChannelCloseTimeout = 5 * time.Second //how long to wait after the data channel has been open before closing the peer connection. // Time after which we assume proxy data channel will not open
defaultStunUrl = "stun:stun.l.google.com:19302" //default STUN URL dataChannelOpenTimeout = 20 * time.Second
// How long to wait after the data channel has been open before closing the peer connection.
dataChannelCloseTimeout = 5 * time.Second
// Default STUN URL
defaultStunUrls = "stun:stun.l.google.com:19302,stun:stun.voip.blackberry.com:3478"
) )
type ProbeHandler struct { type ProbeHandler struct {
@ -60,7 +64,7 @@ func makePeerConnectionFromOffer(stunURL string, sdp *webrtc.SessionDescription,
config := webrtc.Configuration{ config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{ ICEServers: []webrtc.ICEServer{
{ {
URLs: []string{stunURL}, URLs: strings.Split(stunURL, ","),
}, },
}, },
} }
@ -234,7 +238,7 @@ func main() {
flag.StringVar(&addr, "addr", ":8443", "address to listen on") flag.StringVar(&addr, "addr", ":8443", "address to listen on")
flag.BoolVar(&disableTLS, "disable-tls", false, "don't use HTTPS") flag.BoolVar(&disableTLS, "disable-tls", false, "don't use HTTPS")
flag.BoolVar(&unsafeLogging, "unsafe-logging", false, "prevent logs from being scrubbed") flag.BoolVar(&unsafeLogging, "unsafe-logging", false, "prevent logs from being scrubbed")
flag.StringVar(&stunURL, "stun", defaultStunUrl, "STUN server to use for NAT traversal") flag.StringVar(&stunURL, "stun", defaultStunUrls, "STUN servers to use for NAT traversal (comma-separated)")
flag.Parse() flag.Parse()
var logOutput io.Writer = os.Stderr var logOutput io.Writer = os.Stderr

View file

@ -60,7 +60,7 @@ const (
DefaultNATProbeURL = "https://snowflake-broker.torproject.net:8443/probe" DefaultNATProbeURL = "https://snowflake-broker.torproject.net:8443/probe"
// This is rather a "DefaultDefaultRelayURL" // This is rather a "DefaultDefaultRelayURL"
DefaultRelayURL = "wss://snowflake.torproject.net/" DefaultRelayURL = "wss://snowflake.torproject.net/"
DefaultSTUNURL = "stun:stun.l.google.com:19302" DefaultSTUNURL = "stun:stun.l.google.com:19302,stun:stun.voip.blackberry.com:3478"
DefaultProxyType = "standalone" DefaultProxyType = "standalone"
) )
@ -123,7 +123,7 @@ type SnowflakeProxy struct {
// Capacity is the maximum number of clients a Snowflake will serve. // Capacity is the maximum number of clients a Snowflake will serve.
// Proxies with a capacity of 0 will accept an unlimited number of clients. // Proxies with a capacity of 0 will accept an unlimited number of clients.
Capacity uint Capacity uint
// STUNURL is the URL of the STUN server the proxy will use // STUNURL is the URLs (comma-separated) of the STUN server the proxy will use
STUNURL string STUNURL string
// BrokerURL is the URL of the Snowflake broker // BrokerURL is the URL of the Snowflake broker
BrokerURL string BrokerURL string
@ -757,7 +757,7 @@ func (sf *SnowflakeProxy) Start() error {
config = webrtc.Configuration{ config = webrtc.Configuration{
ICEServers: []webrtc.ICEServer{ ICEServers: []webrtc.ICEServer{
{ {
URLs: []string{sf.STUNURL}, URLs: strings.Split(sf.STUNURL, ","),
}, },
}, },
} }

View file

@ -23,7 +23,7 @@ func main() {
pollInterval := flag.Duration("poll-interval", sf.DefaultPollInterval, pollInterval := flag.Duration("poll-interval", sf.DefaultPollInterval,
fmt.Sprint("how often to ask the broker for a new client. Keep in mind that asking for a client will not always result in getting one. Minumum value is ", minPollInterval, ". Valid time units are \"ms\", \"s\", \"m\", \"h\".")) fmt.Sprint("how often to ask the broker for a new client. Keep in mind that asking for a client will not always result in getting one. Minumum value is ", minPollInterval, ". Valid time units are \"ms\", \"s\", \"m\", \"h\"."))
capacity := flag.Uint("capacity", 0, "maximum concurrent clients (default is to accept an unlimited number of clients)") capacity := flag.Uint("capacity", 0, "maximum concurrent clients (default is to accept an unlimited number of clients)")
stunURL := flag.String("stun", sf.DefaultSTUNURL, "STUN server `URL` that this proxy will use will use to, among some other things, determine its public IP address") stunURL := flag.String("stun", sf.DefaultSTUNURL, "Comma-separated STUN server `URL`s that this proxy will use will use to, among some other things, determine its public IP address")
logFilename := flag.String("log", "", "log `filename`. If not specified, logs will be output to stderr (console).") logFilename := flag.String("log", "", "log `filename`. If not specified, logs will be output to stderr (console).")
rawBrokerURL := flag.String("broker", sf.DefaultBrokerURL, "The `URL` of the broker server that the proxy will be using to find clients") rawBrokerURL := flag.String("broker", sf.DefaultBrokerURL, "The `URL` of the broker server that the proxy will be using to find clients")
unsafeLogging := flag.Bool("unsafe-logging", false, "keep IP addresses and other sensitive info in the logs") unsafeLogging := flag.Bool("unsafe-logging", false, "keep IP addresses and other sensitive info in the logs")