(conn net.Conn, targetAddr string)
| 179 | } |
| 180 | |
| 181 | func (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 | |
| 199 | func copyAndClose(wg *sync.WaitGroup, dest io.WriteCloser, src io.Reader) { |
| 200 | _, _ = io.Copy(dest, src) |
no test coverage detected