Skip to content

Commit

Permalink
Merge pull request #403 from vyasgun/pr/ssh-port
Browse files Browse the repository at this point in the history
Disable ssh port forwarding when value of -ssh-port is -1
  • Loading branch information
openshift-merge-bot[bot] authored Oct 7, 2024
2 parents de690ca + ffcc660 commit a89bb10
Showing 1 changed file with 11 additions and 4 deletions.
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

0 comments on commit a89bb10

Please sign in to comment.