Merge pull request 'fix: logic error in port checking' (#8) from staging into main
Some checks failed
Docker Build and Push / build-and-push (push) Has been cancelled

Reviewed-on: bagas/tunnl_please#8
This commit is contained in:
2025-11-28 10:34:28 +00:00
2 changed files with 1 additions and 4 deletions

View File

@ -74,9 +74,6 @@ func (pm *PortManager) SetPortStatus(port uint16, assigned bool) error {
pm.mu.Lock()
defer pm.mu.Unlock()
if _, exists := pm.ports[port]; !exists {
return fmt.Errorf("port %d already in use", port)
}
pm.ports[port] = assigned
return nil
}

View File

@ -271,7 +271,7 @@ func (s *SSHSession) handleTCPIPForward(req *ssh.Request) {
}
return
}
} else if isUse, isExist := portUtil.Manager.GetPortStatus(portToBind); isExist || isUse {
} else if isUse, isExist := portUtil.Manager.GetPortStatus(portToBind); isExist && isUse {
s.interaction.SendMessage(fmt.Sprintf("Port %d is already in use or restricted. Please choose a different port. (03)\r\n", portToBind))
err := req.Reply(false, nil)
if err != nil {