use SSH tunnel if user specifies bindAddress

pull/14951/head
Steven Powell 2022-09-14 11:57:28 -07:00
parent faed0ecefd
commit 012146bdbc
1 changed files with 11 additions and 1 deletions

View File

@ -85,7 +85,7 @@ var tunnelCmd = &cobra.Command{
cancel() cancel()
}() }()
if driver.NeedsPortForward(co.Config.Driver) && driver.IsKIC(co.Config.Driver) { if useSSHTunnel(co.Config.Driver) {
port, err := oci.ForwardedPort(co.Config.Driver, cname, 22) port, err := oci.ForwardedPort(co.Config.Driver, cname, 22)
if err != nil { if err != nil {
exit.Error(reason.DrvPortForward, "error getting ssh port", err) exit.Error(reason.DrvPortForward, "error getting ssh port", err)
@ -111,6 +111,16 @@ var tunnelCmd = &cobra.Command{
}, },
} }
func useSSHTunnel(driverName string) bool {
if !driver.IsKIC(driverName) {
return false
}
if driver.NeedsPortForward(driverName) {
return true
}
return bindAddress != ""
}
func outputTunnelStarted() { func outputTunnelStarted() {
out.Styled(style.Success, "Tunnel successfully started") out.Styled(style.Success, "Tunnel successfully started")
out.Ln("") out.Ln("")