Export ability to change the URL of NAT probe

This commit is contained in:
Cecylia Bocovich 2021-10-26 15:43:36 -04:00
parent 3caa83d84d
commit 0a2598a1e8

View file

@ -49,7 +49,7 @@ import (
const DefaultBrokerURL = "https://snowflake-broker.torproject.net/" const DefaultBrokerURL = "https://snowflake-broker.torproject.net/"
const DefaultProbeURL = "https://snowflake-broker.torproject.net:8443/probe" const DefaultNATProbeURL = "https://snowflake-broker.torproject.net:8443/probe"
const DefaultRelayURL = "wss://snowflake.bamsoftware.com/" const DefaultRelayURL = "wss://snowflake.bamsoftware.com/"
@ -99,6 +99,8 @@ type SnowflakeProxy struct {
KeepLocalAddresses bool KeepLocalAddresses bool
// RelayURL is the URL of the Snowflake server that all traffic will be relayed to // RelayURL is the URL of the Snowflake server that all traffic will be relayed to
RelayURL string RelayURL string
// NATProbeURL is the URL of the probe service we use for NAT checks
NATProbeURL string
shutdown chan struct{} shutdown chan struct{}
} }
@ -499,6 +501,9 @@ func (sf *SnowflakeProxy) Start() error {
if sf.STUNURL == "" { if sf.STUNURL == "" {
sf.STUNURL = DefaultSTUNURL sf.STUNURL = DefaultSTUNURL
} }
if sf.NATProbeURL == "" {
sf.NATProbeURL = DefaultNATProbeURL
}
broker, err = newSignalingServer(sf.BrokerURL, sf.KeepLocalAddresses) broker, err = newSignalingServer(sf.BrokerURL, sf.KeepLocalAddresses)
if err != nil { if err != nil {
@ -524,7 +529,7 @@ func (sf *SnowflakeProxy) Start() error {
tokens = newTokens(sf.Capacity) tokens = newTokens(sf.Capacity)
// use probetest to determine NAT compatability // use probetest to determine NAT compatability
sf.checkNATType(config, DefaultProbeURL) sf.checkNATType(config, sf.NATProbeURL)
log.Printf("NAT type: %s", currentNATType) log.Printf("NAT type: %s", currentNATType)
ticker := time.NewTicker(pollInterval) ticker := time.NewTicker(pollInterval)