Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable ssh port forwarding when value of -ssh-port is -1 #403

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions cmd/gvproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
},
Expand Down Expand Up @@ -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 {
Expand Down
Loading