Copy base client config for each SOCKS connection

Fixes a bug where socksAcceptLoop was reusing the same client config
when processing arguments from multiple SOCKS connections, causing
different bridge lines to clobber each other.
This commit is contained in:
Cecylia Bocovich 2025-02-19 14:33:32 -05:00
parent 5f7e23813d
commit eb13b2ff4b
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90

View file

@ -60,7 +60,8 @@ func copyLoop(socks, sfconn io.ReadWriter) {
}
// Accept local SOCKS connections and connect to a Snowflake connection
func socksAcceptLoop(ln *pt.SocksListener, config sf.ClientConfig, shutdown chan struct{}, wg *sync.WaitGroup) {
func socksAcceptLoop(ln *pt.SocksListener, baseConfig sf.ClientConfig,
shutdown chan struct{}, wg *sync.WaitGroup) {
defer ln.Close()
for {
conn, err := ln.AcceptSocks()
@ -77,6 +78,7 @@ func socksAcceptLoop(ln *pt.SocksListener, config sf.ClientConfig, shutdown chan
defer wg.Done()
defer conn.Close()
config := baseConfig
// Check to see if our command line options are overriden by SOCKS options
if arg, ok := conn.Req.Args.Get("ampcache"); ok {
config.AmpCacheURL = arg