ForwardPorts formats and executes a port forwarding request. The connection will remain open until stopChan is closed.
()
| 186 | // ForwardPorts formats and executes a port forwarding request. The connection will remain |
| 187 | // open until stopChan is closed. |
| 188 | func (pf *PortForwarder) ForwardPorts() error { |
| 189 | defer pf.Close() |
| 190 | |
| 191 | var err error |
| 192 | pf.streamConn, _, err = pf.dialer.Dial(PortForwardProtocolV1Name) |
| 193 | if err != nil { |
| 194 | return fmt.Errorf("error upgrading connection: %s", err) |
| 195 | } |
| 196 | defer pf.streamConn.Close() |
| 197 | |
| 198 | return pf.forward() |
| 199 | } |
| 200 | |
| 201 | // forward dials the remote host specific in req, upgrades the request, starts |
| 202 | // listeners for each port specified in ports, and forwards local connections |