MCPcopy
hub / github.com/cloudfoundry/cli / handleForwardConnection

Method handleForwardConnection

cf/ssh/ssh.go:181–197  ·  view source on GitHub ↗
(conn net.Conn, targetAddr string)

Source from the content-addressed store, hash-verified

179}
180
181func (c *secureShell) handleForwardConnection(conn net.Conn, targetAddr string) {
182 defer conn.Close()
183
184 target, err := c.secureClient.Dial("tcp", targetAddr)
185 if err != nil {
186 fmt.Printf("connect to %s failed: %s\n", targetAddr, err.Error())
187 return
188 }
189 defer target.Close()
190
191 wg := &sync.WaitGroup{}
192 wg.Add(2)
193
194 go copyAndClose(wg, conn, target)
195 go copyAndClose(wg, target, conn)
196 wg.Wait()
197}
198
199func copyAndClose(wg *sync.WaitGroup, dest io.WriteCloser, src io.Reader) {
200 _, _ = io.Copy(dest, src)

Callers 1

Calls 7

copyAndCloseFunction · 0.70
CloseMethod · 0.65
DialMethod · 0.65
PrintfMethod · 0.65
ErrorMethod · 0.65
AddMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected