fix: logic error in port checking #8
@ -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
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user