Skip to content

Commit 28fcd30

Browse files
authored
Make tunnel-ssh options configurable (#1531)
Fixes #1529
1 parent c825e14 commit 28fcd30

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/base-driver/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { createLogger } from '@sqltools/log';
1717
import path from 'path';
1818
import fs from 'fs';
1919
import { URI } from 'vscode-uri';
20-
import { createTunnel } from 'tunnel-ssh';
20+
import { createTunnel, TunnelOptions } from 'tunnel-ssh';
2121
import { AddressInfo } from 'net';
2222

2323
export default abstract class AbstractDriver<ConnectionType extends any, DriverOptions extends any> implements IConnectionDriver {
@@ -142,12 +142,14 @@ export default abstract class AbstractDriver<ConnectionType extends any, DriverO
142142
db: {
143143
host: string;
144144
port: number;
145-
}
145+
},
146+
tunnelOptions?: Partial<TunnelOptions>
146147
) {
147148
const [sshTunnel] = await createTunnel(
148149
{
149150
autoClose: true,
150151
reconnectOnError: false,
152+
...tunnelOptions,
151153
},
152154
null,
153155
{
@@ -164,6 +166,9 @@ export default abstract class AbstractDriver<ConnectionType extends any, DriverO
164166
);
165167
return {
166168
port: (sshTunnel.address() as AddressInfo).port,
169+
close: () => {
170+
sshTunnel.close();
171+
},
167172
};
168173
}
169174

0 commit comments

Comments
 (0)