* Forward a connection through an SSH client to a target host.
(client: Client, targetHost: string, targetPort: number)
| 236 | * Forward a connection through an SSH client to a target host. |
| 237 | */ |
| 238 | private forwardTo(client: Client, targetHost: string, targetPort: number): Promise<Duplex> { |
| 239 | return new Promise((resolve, reject) => { |
| 240 | client.forwardOut('127.0.0.1', 0, targetHost, targetPort, (err, stream) => { |
| 241 | if (err) { |
| 242 | reject(new Error(`SSH forward error: ${err.message}`)); |
| 243 | return; |
| 244 | } |
| 245 | resolve(stream as Duplex); |
| 246 | }); |
| 247 | }); |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Create the local server that tunnels connections to the database. |