aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArlo Breault <arlolra@gmail.com>2022-03-10 14:13:35 -0500
committerArlo Breault <arlolra@gmail.com>2022-03-16 16:33:24 -0400
commitbd636a1374efb514bbc40acbd1dcaf0ecec26916 (patch)
treebf457af9e3acf29e10bfbb32522abf94dc2c72cb
parent829cacac5f7ecb2cc701a24061679814fc1841bc (diff)
downloadsnowflake-bd636a1374efb514bbc40acbd1dcaf0ecec26916.tar.gz
snowflake-bd636a1374efb514bbc40acbd1dcaf0ecec26916.zip
Introduce an unexported newBrokerChannelFromConfig
A follow-up wants to pass in a new property from the ClientConfig but it would be an API breaking change to NewBrokerChannel. However, it's unclear why NewBrokerChannel is exported at all. No other package in the repo depends on it and the known users of the library probably wouldn't be construct them. While this patch was being reviewed, a new constructor was added, NewBrokerChannelWithUTLSSettings, with effectively the same issue. Both of those exported ones are deleted here.
-rw-r--r--client/lib/rendezvous.go38
-rw-r--r--client/lib/snowflake.go4
2 files changed, 17 insertions, 25 deletions
diff --git a/client/lib/rendezvous.go b/client/lib/rendezvous.go
index e7543ad..73c62ed 100644
--- a/client/lib/rendezvous.go
+++ b/client/lib/rendezvous.go
@@ -55,40 +55,34 @@ func createBrokerTransport() http.RoundTripper {
return transport
}
-func NewBrokerChannel(broker, ampCache, front string, keepLocalAddresses bool) (*BrokerChannel, error) {
- return NewBrokerChannelWithUTLSSettings(broker, ampCache, front, keepLocalAddresses, "", false)
-}
+func newBrokerChannelFromConfig(config ClientConfig) (*BrokerChannel, error) {
+ log.Println("Rendezvous using Broker at:", config.BrokerURL)
-// NewBrokerChannelWithUTLSSettings construct a new BrokerChannel, where:
-// |broker| is the full URL of the facilitating program which assigns proxies
-// to clients, and |front| is the option fronting domain.
-func NewBrokerChannelWithUTLSSettings(broker, ampCache, front string, keepLocalAddresses bool,
- uTLSClientID string, removeSNI bool) (*BrokerChannel, error) {
- log.Println("Rendezvous using Broker at:", broker)
- if ampCache != "" {
- log.Println("Through AMP cache at:", ampCache)
- }
- if front != "" {
- log.Println("Domain fronting using:", front)
+ if config.FrontDomain != "" {
+ log.Println("Domain fronting using:", config.FrontDomain)
}
brokerTransport := createBrokerTransport()
- if uTLSClientID != "" {
- utlsClientHelloID, err := utlsutil.NameToUTLSID(uTLSClientID)
+ if config.UTLSClientID != "" {
+ utlsClientHelloID, err := utlsutil.NameToUTLSID(config.UTLSClientID)
if err != nil {
return nil, fmt.Errorf("unable to create broker channel: %v", err)
}
- config := &utls.Config{}
- brokerTransport = utlsutil.NewUTLSHTTPRoundTripper(utlsClientHelloID, config, brokerTransport, removeSNI)
+ utlsConfig := &utls.Config{}
+ brokerTransport = utlsutil.NewUTLSHTTPRoundTripper(utlsClientHelloID, utlsConfig, brokerTransport, config.UTLSRemoveSNI)
}
var rendezvous RendezvousMethod
var err error
- if ampCache != "" {
- rendezvous, err = newAMPCacheRendezvous(broker, ampCache, front, brokerTransport)
+ if config.AmpCacheURL != "" {
+ log.Println("Through AMP cache at:", config.AmpCacheURL)
+ rendezvous, err = newAMPCacheRendezvous(
+ config.BrokerURL, config.AmpCacheURL, config.FrontDomain,
+ brokerTransport)
} else {
- rendezvous, err = newHTTPRendezvous(broker, front, brokerTransport)
+ rendezvous, err = newHTTPRendezvous(
+ config.BrokerURL, config.FrontDomain, brokerTransport)
}
if err != nil {
return nil, err
@@ -96,7 +90,7 @@ func NewBrokerChannelWithUTLSSettings(broker, ampCache, front string, keepLocalA
return &BrokerChannel{
Rendezvous: rendezvous,
- keepLocalAddresses: keepLocalAddresses,
+ keepLocalAddresses: config.KeepLocalAddresses,
natType: nat.NATUnknown,
}, nil
}
diff --git a/client/lib/snowflake.go b/client/lib/snowflake.go
index 1c6c381..1b236a6 100644
--- a/client/lib/snowflake.go
+++ b/client/lib/snowflake.go
@@ -131,9 +131,7 @@ func NewSnowflakeClient(config ClientConfig) (*Transport, error) {
}
// Rendezvous with broker using the given parameters.
- broker, err := NewBrokerChannelWithUTLSSettings(
- config.BrokerURL, config.AmpCacheURL, config.FrontDomain,
- config.KeepLocalAddresses, config.UTLSClientID, config.UTLSRemoveSNI)
+ broker, err := newBrokerChannelFromConfig(config)
if err != nil {
return nil, err
}