diff --git a/sshmuxer/aliashandler.go b/sshmuxer/aliashandler.go index de1407d..2dbd0f7 100644 --- a/sshmuxer/aliashandler.go +++ b/sshmuxer/aliashandler.go @@ -19,7 +19,7 @@ import ( func handleAliasListener(check *channelForwardMsg, stringPort string, requestMessages string, listenerHolder *utils.ListenerHolder, state *utils.State, sshConn *utils.SSHConnection) (*utils.AliasHolder, *url.URL, string, string, error) { validAlias, aH := utils.GetOpenAlias(check.Addr, stringPort, state, sshConn) - if !strings.HasPrefix(validAlias, check.Addr) && viper.GetBool("force-requested-aliases") { + if !strings.HasPrefix(validAlias, check.Addr) && viper.GetBool("force-requested-aliases") || validAlias == "" { return nil, nil, "", "", fmt.Errorf("error assigning requested alias to tunnel") } diff --git a/sshmuxer/requests.go b/sshmuxer/requests.go index 7467920..6431e86 100644 --- a/sshmuxer/requests.go +++ b/sshmuxer/requests.go @@ -58,6 +58,8 @@ func handleRemoteForward(newRequest *ssh.Request, sshConn *utils.SSHConnection, log.Println("Error unmarshaling remote forward payload:", err) } + check.Addr = strings.ToLower(check.Addr) + bindPort := check.Rport stringPort := strconv.FormatUint(uint64(bindPort), 10) diff --git a/utils/utils.go b/utils/utils.go index 7affe2f..bc97f12 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -928,7 +928,7 @@ func GetOpenAlias(addr string, port string, state *State, sshConn *SSHConnection if viper.GetBool("force-requested-aliases") { extra = "" - bindErr = fmt.Errorf("unable to bind requested port") + bindErr = fmt.Errorf("unable to bind requested alias") } sshConn.SendMessage(aurora.Sprintf("The alias %s is unavailable.%s", aurora.Red(alias), extra), true) @@ -960,6 +960,10 @@ func GetOpenAlias(addr string, port string, state *State, sshConn *SSHConnection for checkAlias(alias) { } + if bindErr != nil { + return "", nil + } + return alias, aH }