Skip to content

Commit 1ef645d

Browse files
authored
feat(bindings): Use HTTPS proxy when provided as environment variable
1 parent 57e09c0 commit 1ef645d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

bindings/matrix-sdk-crypto-nodejs/download-lib.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Agent } = require('https');
1+
const { HttpsProxyAgent } = require('https-proxy-agent');
22
const { DownloaderHelper } = require('node-downloader-helper');
33
const { version } = require("./package.json");
44
const { platform, arch } = process
@@ -23,13 +23,16 @@ function download_lib(libname) {
2323
console.info(`Downloading lib ${libname} from ${url}`);
2424
const dl = new DownloaderHelper(url, __dirname, {
2525
override: true,
26-
httpsRequestOptions: {
27-
// Disable keepalive to prevent the process hanging open.
28-
// https://github.com/matrix-org/matrix-rust-sdk/issues/1160
29-
agent: new Agent({ keepAlive: false }),
30-
},
3126
});
3227

28+
const proxy = process.env.https_proxy ?? process.env.HTTPS_PROXY;
29+
if (proxy) {
30+
const proxyAgent = new HttpsProxyAgent(proxy);
31+
dl.updateOptions({
32+
httpsRequestOptions: { agent: proxyAgent },
33+
});
34+
}
35+
3336
dl.on('end', () => console.info('Download Completed'));
3437
dl.on('error', (err) => console.info('Download Failed', err));
3538
dl.on('progress', stats => {

bindings/matrix-sdk-crypto-nodejs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"doc": "typedoc --tsconfig ."
3030
},
3131
"dependencies": {
32-
"node-downloader-helper": "^2.1.1"
32+
"https-proxy-agent": "^5.0.1",
33+
"node-downloader-helper": "^2.1.5"
3334
}
3435
}

0 commit comments

Comments
 (0)