(ctx devspacecontext.Context, name, arch string, remotePort int, reverseCommands []*latest.ProxyCommand, selector targetselector.TargetSelector, parent *tomb.Tomb)
| 51 | } |
| 52 | |
| 53 | func startProxyCommands(ctx devspacecontext.Context, name, arch string, remotePort int, reverseCommands []*latest.ProxyCommand, selector targetselector.TargetSelector, parent *tomb.Tomb) error { |
| 54 | if ctx.IsDone() { |
| 55 | return nil |
| 56 | } |
| 57 | |
| 58 | // get a local port |
| 59 | port, err := ssh.GetInstance(ctx.Log()).LockPort() |
| 60 | if err != nil { |
| 61 | return errors.Wrap(err, "find port") |
| 62 | } |
| 63 | |
| 64 | defer ssh.GetInstance(ctx.Log()).ReleasePort(port) |
| 65 | |
| 66 | // start reverse port forwarding from that port |
| 67 | mapping := fmt.Sprintf("%d:%d", port, remotePort) |
| 68 | err = portforwarding.StartReversePortForwarding(ctx, name, arch, []*latest.PortMapping{ |
| 69 | { |
| 70 | Port: mapping, |
| 71 | }, |
| 72 | }, selector, parent) |
| 73 | if err != nil { |
| 74 | return errors.Wrap(err, "start ssh port forwarding") |
| 75 | } |
| 76 | |
| 77 | // start ssh |
| 78 | return startLocalSSH(ctx, selector, reverseCommands, remotePort, fmt.Sprintf(":%d", port), parent) |
| 79 | } |
| 80 | |
| 81 | func startLocalSSH(ctx devspacecontext.Context, selector targetselector.TargetSelector, reverseCommands []*latest.ProxyCommand, remotePort int, addr string, parent *tomb.Tomb) error { |
| 82 | if ctx.IsDone() { |
no test coverage detected