Skip to content

Commit 745ea79

Browse files
author
EspressoTrip-v2
committed
update patch
1 parent 2dea325 commit 745ea79

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/mongoPatch.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as socks from 'socks';
2+
import * as tls from 'tls';
23
import {HttpsProxySocket} from './HttpsProxySocket';
34

45
interface Config {
@@ -12,13 +13,17 @@ interface Config {
1213
* @param config - The configuration for the proxy
1314
*/
1415
export function useProxyForMongo(config: Config) {
16+
let socket: tls.TLSSocket
1517
socks.SocksClient.createConnection = async (options, callback) => {
1618
const proxy = new HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
1719
return new Promise(async (resolve, reject) => {
18-
const socket = await proxy.connect({ host: options.destination.host, port: options.destination.port });
20+
socket = await proxy.connect({ host: options.destination.host, port: options.destination.port });
1921
resolve({
2022
socket,
2123
});
2224
});
2325
};
26+
return {
27+
close: () => socket?.end()
28+
}
2429
}

0 commit comments

Comments
 (0)