diff --git a/cmd/gvproxy/main.go b/cmd/gvproxy/main.go index 13e92c292..09d7931d6 100644 --- a/cmd/gvproxy/main.go +++ b/cmd/gvproxy/main.go @@ -167,7 +167,7 @@ func main() { // If the given port is not between the privileged ports // and the oft considered maximum port, return an error. - if sshPort < 1024 || sshPort > 65535 { + if sshPort != -1 && sshPort < 1024 || sshPort > 65535 { exitWithError(errors.New("ssh-port value must be between 1024 and 65535")) } protocol := types.HyperKitProtocol @@ -250,9 +250,7 @@ func main() { }, }, DNSSearchDomains: searchDomains(), - Forwards: map[string]string{ - fmt.Sprintf("127.0.0.1:%d", sshPort): sshHostPort, - }, + Forwards: getForwardsMap(sshPort, sshHostPort), NAT: map[string]string{ hostIP: "127.0.0.1", }, @@ -285,6 +283,15 @@ func main() { } } +func getForwardsMap(sshPort int, sshHostPort string) map[string]string { + if sshPort == -1 { + return map[string]string{} + } + return map[string]string{ + fmt.Sprintf("127.0.0.1:%d", sshPort): sshHostPort, + } +} + type arrayFlags []string func (i *arrayFlags) String() string {