refactor: remove unuse variable and channel
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 6m13s
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 6m13s
This commit is contained in:
@ -177,22 +177,6 @@ func (s *Session) handleTCPIPForward(req *ssh.Request) {
|
|||||||
return
|
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")
|
s.sendMessage("\033[H\033[2J")
|
||||||
|
|
||||||
showWelcomeMessage(s.ConnChannel)
|
showWelcomeMessage(s.ConnChannel)
|
||||||
@ -202,6 +186,21 @@ func (s *Session) handleTCPIPForward(req *ssh.Request) {
|
|||||||
s.handleHTTPForward(req, portToBind)
|
s.handleHTTPForward(req, portToBind)
|
||||||
return
|
return
|
||||||
} else {
|
} 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)
|
portUtil.Manager.SetPortStatus(portToBind, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user