Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.24.0
toolchain go1.24.6

require (
github.com/coder/websocket v1.8.14
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
github.com/rancher/dynamiclistener v0.7.3-rc.1
github.com/rancher/remotedialer v0.6.0-rc.1
github.com/rancher/wrangler/v3 v3.3.1
Expand All @@ -32,6 +32,7 @@ require (
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand Down Expand Up @@ -71,3 +72,5 @@ require (
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)

replace github.com/rancher/remotedialer => github.com/commitgo/remotedialer v0.0.0-20251206042109-bfe21d19229c
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
github.com/commitgo/remotedialer v0.0.0-20251206042109-bfe21d19229c h1:nfeiY7eT0Yku/9WxU3FsmlwtYLyk8c3hhpUCtxVDQFU=
github.com/commitgo/remotedialer v0.0.0-20251206042109-bfe21d19229c/go.mod h1:moyd+I/6xt+z3MX74aXomNRvYZc9iCdsVKkaPTKxRDk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down Expand Up @@ -86,8 +90,6 @@ github.com/rancher/dynamiclistener v0.7.3-rc.1 h1:F4Et+TaL8RcXTdTvJKuj6OL5Gg1I1I
github.com/rancher/dynamiclistener v0.7.3-rc.1/go.mod h1:++39p1G3pz0N7yRzvZsjc+5x4l0cMUi2jo49Fy+IbCE=
github.com/rancher/lasso v0.2.5 h1:K++lWDDdfeN98Ixc1kCfUq0/q6tLjoHN++Np6QntXw0=
github.com/rancher/lasso v0.2.5/go.mod h1:71rWfv+KkdSmSxZ9Ly5QYhxAu0nEUcaq9N2ByjcHqAM=
github.com/rancher/remotedialer v0.6.0-rc.1 h1:HMwcJjjT4irqM+d++jPcpjoNfhPCaxoHIyPzdpghZhE=
github.com/rancher/remotedialer v0.6.0-rc.1/go.mod h1:CW6Q8F8IESN05/yl48OSwhVi54nDwVQQriV16zAiGkg=
github.com/rancher/wrangler/v3 v3.3.1 h1:YFqRfhxjuLNudUrvWrn+64wUPZ8pnn2KWbTsha75JLg=
github.com/rancher/wrangler/v3 v3.3.1/go.mod h1:0D4kZDaOUkP5W2Zfww/75tQwF9w7kaZgzpZG+4XQDAI=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
Expand Down
3 changes: 1 addition & 2 deletions proxy/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"testing"
"time"

"github.com/gorilla/websocket"
"github.com/rancher/remotedialer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -62,7 +61,7 @@ func TestRunProxyListener(t *testing.T) {
// ClientConnect will exit when the context is cancelled or the connection is otherwise lost.
headers := http.Header{}
headers.Set("X-API-Tunnel-Secret", "test-secret")
err := remotedialer.ClientConnect(ctx, wsURL, headers, websocket.DefaultDialer, connectAuthorizer, onConnect)
err := remotedialer.ClientConnect(ctx, wsURL, headers, nil, connectAuthorizer, onConnect)
// No error on clean context cancellation
if ctx.Err() == nil && err != nil {
t.Errorf("remotedialer client connect error: %v", err)
Expand Down
48 changes: 26 additions & 22 deletions proxyclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sync"
"time"

"github.com/gorilla/websocket"
"github.com/coder/websocket"
"github.com/rancher/remotedialer"
v1 "github.com/rancher/wrangler/v3/pkg/generated/controllers/core/v1"

Expand Down Expand Up @@ -38,8 +38,8 @@ type ProxyClient struct {
serverUrl string
serverConnectSecret string

dialer *websocket.Dialer
dialerMtx sync.Mutex
dialOpts *websocket.DialOptions
dialOptsMtx sync.Mutex

secretController v1.SecretController
namespace string
Expand Down Expand Up @@ -103,14 +103,18 @@ func (c *ProxyClient) setUpBuildDialerCallback(ctx context.Context, certSecretNa
return nil, err
}

c.dialerMtx.Lock()
c.dialer = &websocket.Dialer{
TLSClientConfig: &tls.Config{
RootCAs: rootCAs,
ServerName: c.certServerName,
c.dialOptsMtx.Lock()
c.dialOpts = &websocket.DialOptions{
HTTPClient: &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
RootCAs: rootCAs,
ServerName: c.certServerName,
},
},
},
}
c.dialerMtx.Unlock()
c.dialOptsMtx.Unlock()
logrus.Infof("RDPClient: certificate updated successfully")
}

Expand Down Expand Up @@ -142,18 +146,18 @@ func (c *ProxyClient) Run(ctx context.Context) {
return

default:
logrus.Info("RDPClient: Checking if dialer is built...")
logrus.Info("RDPClient: Checking if dialOpts is built...")

c.dialerMtx.Lock()
dialer := c.dialer
c.dialerMtx.Unlock()
c.dialOptsMtx.Lock()
dialOpts := c.dialOpts
c.dialOptsMtx.Unlock()

if dialer != nil {
logrus.Info("RDPClient: Dialer is built. Ready to start.")
if dialOpts != nil {
logrus.Info("RDPClient: DialOpts is built. Ready to start.")
break LookForDialer
}

logrus.Infof("RDPClient: Dialer is not built yet, waiting %d secs to re-check.", getSecretRetryTimeout/time.Second)
logrus.Infof("RDPClient: DialOpts is not built yet, waiting %d secs to re-check.", getSecretRetryTimeout/time.Second)
time.Sleep(getSecretRetryTimeout)
}
}
Expand Down Expand Up @@ -185,11 +189,11 @@ func (c *ProxyClient) Run(ctx context.Context) {
return nil
}

c.dialerMtx.Lock()
dialer := c.dialer
c.dialerMtx.Unlock()
c.dialOptsMtx.Lock()
dialOpts := c.dialOpts
c.dialOptsMtx.Unlock()

if err := remotedialer.ClientConnect(ctx, c.serverUrl, headers, dialer, onConnectAuth, onConnect); err != nil {
if err := remotedialer.ClientConnect(ctx, c.serverUrl, headers, dialOpts, onConnectAuth, onConnect); err != nil {
logrus.Errorf("RDPClient: remotedialer.ClientConnect error: %s", err.Error())
c.forwarder.Stop()
time.Sleep(retryTimeout)
Expand Down Expand Up @@ -218,8 +222,8 @@ func WithOnConnectCallback(onConnect func(ctx context.Context, session *remotedi
}
}

func WithCustomDialer(dialer *websocket.Dialer) ProxyClientOpt {
func WithCustomDialOptions(dialOpts *websocket.DialOptions) ProxyClientOpt {
return func(pc *ProxyClient) {
pc.dialer = dialer
pc.dialOpts = dialOpts
}
}