Default to a maximum value of 1 Snowflake peer

This commit is contained in:
Cecylia Bocovich 2021-09-29 15:48:31 -04:00
parent 6c6a2e44ab
commit 5927c2bdf9

View file

@ -8,7 +8,6 @@ specification. To use Snowflake, you must first create a client from a configura
config := snowflake_client.ClientConfig{ config := snowflake_client.ClientConfig{
BrokerURL: "https://snowflake-broker.example.com", BrokerURL: "https://snowflake-broker.example.com",
FrontDomain: "https://friendlyfrontdomain.net", FrontDomain: "https://friendlyfrontdomain.net",
Max: 1,
// ... // ...
} }
transport, err := snowflake_client.NewSnowflakeClient(config) transport, err := snowflake_client.NewSnowflakeClient(config)
@ -91,7 +90,7 @@ type ClientConfig struct {
// and testing. // and testing.
KeepLocalAddresses bool KeepLocalAddresses bool
// Max is the maximum number of snowflake proxy peers that the client should attempt to // Max is the maximum number of snowflake proxy peers that the client should attempt to
// connect to. // connect to. Defaults to 1.
Max int Max int
} }
@ -128,7 +127,11 @@ func NewSnowflakeClient(config ClientConfig) (*Transport, error) {
} }
go updateNATType(iceServers, broker) go updateNATType(iceServers, broker)
transport := &Transport{dialer: NewWebRTCDialer(broker, iceServers, config.Max)} max := 1
if config.Max > max {
max = config.Max
}
transport := &Transport{dialer: NewWebRTCDialer(broker, iceServers, max)}
return transport, nil return transport, nil
} }