File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as socks from 'socks' ;
2+ import * as tls from 'tls' ;
23import { HttpsProxySocket } from './HttpsProxySocket' ;
34
45interface Config {
@@ -12,13 +13,17 @@ interface Config {
1213 * @param config - The configuration for the proxy
1314 */
1415export 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}
You can’t perform that action at this time.
0 commit comments