From 9276430fae83b92aceed96f47d93928acaa468f4 Mon Sep 17 00:00:00 2001 From: bagas Date: Wed, 31 Dec 2025 18:33:47 +0700 Subject: [PATCH] refactor(session): add registry to manage SSH sessions - Implement thread-safe session registry with sync.RWMutex - Add Registry interface for session management operations - Support Get, Register, Update, and Remove session operations - Enable dynamic slug updates for existing sessions - Fix Connection closed by remote because HandleTCPIPForward run on a goroutine --- session/handler.go | 1 - session/interaction/interaction.go | 5 +++++ session/session.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/session/handler.go b/session/handler.go index c56002e..30458fb 100644 --- a/session/handler.go +++ b/session/handler.go @@ -106,7 +106,6 @@ func (s *SSHSession) HandleTCPIPForward(req *ssh.Request) { } portToBind := uint16(rawPortToBind) - if isBlockedPort(portToBind) { log.Printf("Port %d is blocked or restricted", portToBind) err := req.Reply(false, nil) diff --git a/session/interaction/interaction.go b/session/interaction/interaction.go index 461e31e..2b24e60 100644 --- a/session/interaction/interaction.go +++ b/session/interaction/interaction.go @@ -199,6 +199,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } if m.editingSlug { + if m.tunnelType != types.HTTP { + m.editingSlug = false + m.slugError = "" + return m, tea.Batch(tea.ClearScreen, textinput.Blink) + } switch msg.String() { case "esc": m.editingSlug = false diff --git a/session/session.go b/session/session.go index 025e442..9a35770 100644 --- a/session/session.go +++ b/session/session.go @@ -92,7 +92,7 @@ func (s *SSHSession) Start() error { s.lifecycle.SetChannel(ch) s.interaction.SetChannel(ch) - go s.HandleTCPIPForward(tcpipReq) + s.HandleTCPIPForward(tcpipReq) if err := s.lifecycle.Close(); err != nil { log.Printf("failed to close session: %v", err)