diff --git a/bindings/matrix-sdk-crypto-nodejs/download-lib.js b/bindings/matrix-sdk-crypto-nodejs/download-lib.js index d0aec7d7880..6e360db133c 100644 --- a/bindings/matrix-sdk-crypto-nodejs/download-lib.js +++ b/bindings/matrix-sdk-crypto-nodejs/download-lib.js @@ -1,4 +1,4 @@ -const { Agent } = require('https'); +const { HttpsProxyAgent } = require('https-proxy-agent'); const { DownloaderHelper } = require('node-downloader-helper'); const { version } = require("./package.json"); const { platform, arch } = process @@ -23,13 +23,16 @@ function download_lib(libname) { console.info(`Downloading lib ${libname} from ${url}`); const dl = new DownloaderHelper(url, __dirname, { override: true, - httpsRequestOptions: { - // Disable keepalive to prevent the process hanging open. - // https://github.com/matrix-org/matrix-rust-sdk/issues/1160 - agent: new Agent({ keepAlive: false }), - }, }); + const proxy = process.env.https_proxy ?? process.env.HTTPS_PROXY; + if (proxy) { + const proxyAgent = new HttpsProxyAgent(proxy); + dl.updateOptions({ + httpsRequestOptions: { agent: proxyAgent }, + }); + } + dl.on('end', () => console.info('Download Completed')); dl.on('error', (err) => console.info('Download Failed', err)); dl.on('progress', stats => { diff --git a/bindings/matrix-sdk-crypto-nodejs/package.json b/bindings/matrix-sdk-crypto-nodejs/package.json index c4c1e875a23..d858158e25c 100644 --- a/bindings/matrix-sdk-crypto-nodejs/package.json +++ b/bindings/matrix-sdk-crypto-nodejs/package.json @@ -29,6 +29,7 @@ "doc": "typedoc --tsconfig ." }, "dependencies": { - "node-downloader-helper": "^2.1.1" + "https-proxy-agent": "^5.0.1", + "node-downloader-helper": "^2.1.5" } }