refactor: remove unuse variable and channel
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 6m13s

This commit is contained in:
2025-07-21 14:19:58 +07:00
parent 8c15da6131
commit 0ada07400d

View File

@ -177,22 +177,6 @@ func (s *Session) handleTCPIPForward(req *ssh.Request) {
return
}
if portToBind == 0 {
unassign, success := portUtil.Manager.GetUnassignedPort()
portToBind = unassign
if !success {
s.sendMessage(fmt.Sprintf("No available port\r\n", portToBind))
req.Reply(false, nil)
s.Close()
return
}
} else if isUse, isExist := portUtil.Manager.GetPortStatus(portToBind); !isExist || isUse {
s.sendMessage(fmt.Sprintf("Port %d is already in use or restricted. Please choose a different port. (03)\r\n", portToBind))
req.Reply(false, nil)
s.Close()
return
}
s.sendMessage("\033[H\033[2J")
showWelcomeMessage(s.ConnChannel)
@ -202,6 +186,21 @@ func (s *Session) handleTCPIPForward(req *ssh.Request) {
s.handleHTTPForward(req, portToBind)
return
} else {
if portToBind == 0 {
unassign, success := portUtil.Manager.GetUnassignedPort()
portToBind = unassign
if !success {
s.sendMessage(fmt.Sprintf("No available port\r\n", portToBind))
req.Reply(false, nil)
s.Close()
return
}
} else if isUse, isExist := portUtil.Manager.GetPortStatus(portToBind); !isExist || isUse {
s.sendMessage(fmt.Sprintf("Port %d is already in use or restricted. Please choose a different port. (03)\r\n", portToBind))
req.Reply(false, nil)
s.Close()
return
}
portUtil.Manager.SetPortStatus(portToBind, true)
}