From 598da944f20df9d01201086b35c08ca5c19a6772 Mon Sep 17 00:00:00 2001 From: Zac Bergquist Date: Sat, 2 Dec 2023 18:32:48 -0700 Subject: [PATCH] Default desktop port to 3389 if not specified When specifying hosts in the config file, Teleport will automatically set the port to 3389 if it is not otherwise specified. This behavior is different with tctl or our API - in these cases, we don't default to the correct port, and attempts to connect to these desktops will fail. We now parse the desktop addr at connect time and set the port if it is not provided. Closes #31646 --- lib/srv/desktop/windows_server.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/srv/desktop/windows_server.go b/lib/srv/desktop/windows_server.go index 91c0e19fbb6f7..f39d7678aeb4c 100644 --- a/lib/srv/desktop/windows_server.go +++ b/lib/srv/desktop/windows_server.go @@ -800,8 +800,7 @@ func (s *WindowsService) handleConnection(proxyConn *tls.Conn) { return } if len(desktops) == 0 { - log.Error("no windows desktops with HostID %s and Name %s", s.cfg.Heartbeat.HostUUID, - desktopName) + log.Errorf("desktop %v/%v not found", s.cfg.Heartbeat.HostUUID, desktopName) sendTDPError(fmt.Sprintf("Could not find desktop %v.", desktopName)) return } @@ -835,6 +834,11 @@ func (s *WindowsService) connectRDP(ctx context.Context, log logrus.FieldLogger, return trace.Wrap(err) } + addr, err := utils.ParseHostPortAddr(desktop.GetAddr(), defaults.RDPListenPort) + if err != nil { + return trace.Wrap(err) + } + sessionID := session.NewID() // in order for the session to be recorded, the cluster's session recording mode must @@ -906,7 +910,7 @@ func (s *WindowsService) connectRDP(ctx context.Context, log logrus.FieldLogger, return s.generateUserCert(ctx, username, ttl, desktop, createUsers, groups) }, CertTTL: windows.CertTTL, - Addr: desktop.GetAddr(), + Addr: addr.String(), Conn: tdpConn, AuthorizeFn: authorize, AllowClipboard: authCtx.Checker.DesktopClipboard(),